Skip to content

Commit

Permalink
fix: Do not strip :00 seconds from !!timestamp values (#578)
Browse files Browse the repository at this point in the history
  • Loading branch information
qraynaud authored Oct 27, 2024
1 parent 5850600 commit 2e85b91
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/schema/yaml-1.1/timestamp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,5 @@ export const timestamp: ScalarTag & { test: RegExp } = {
},

stringify: ({ value }) =>
(value as Date).toISOString().replace(/((T00:00)?:00)?\.000Z$/, '')
(value as Date).toISOString().replace(/(T00:00:00)?\.000Z$/, '')
}
3 changes: 3 additions & 0 deletions tests/doc/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,7 @@ english: null
---
canonical: 2001-12-15T02:59:43.1Z
valid iso8601: 2001-12-14t21:59:43.10-05:00
no secs: 2001-12-15T02:59:00
space separated: 2001-12-14 21:59:43.10 -5
no time zone (Z): 2001-12-15 2:59:43.10
date (00:00:00Z): 2002-12-14`
Expand All @@ -671,6 +672,7 @@ date (00:00:00Z): 2002-12-14`
expect(doc.toJSON()).toMatchObject({
canonical: '2001-12-15T02:59:43.100Z',
'valid iso8601': '2001-12-15T02:59:43.100Z',
'no secs': '2001-12-15T02:59:00.000Z',
'space separated': '2001-12-15T02:59:43.100Z',
'no time zone (Z)': '2001-12-15T02:59:43.100Z',
'date (00:00:00Z)': '2002-12-14T00:00:00.000Z'
Expand All @@ -679,6 +681,7 @@ date (00:00:00Z): 2002-12-14`
---
canonical: 2001-12-15T02:59:43.100Z
valid iso8601: 2001-12-15T02:59:43.100Z
no secs: 2001-12-15T02:59:00
space separated: 2001-12-15T02:59:43.100Z
no time zone (Z): 2001-12-15T02:59:43.100Z
date (00:00:00Z): 2002-12-14\n`)
Expand Down

0 comments on commit 2e85b91

Please sign in to comment.