Skip to content

Commit 2e85b91

Browse files
authored
fix: Do not strip :00 seconds from !!timestamp values (#578)
1 parent 5850600 commit 2e85b91

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/schema/yaml-1.1/timestamp.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,5 +116,5 @@ export const timestamp: ScalarTag & { test: RegExp } = {
116116
},
117117

118118
stringify: ({ value }) =>
119-
(value as Date).toISOString().replace(/((T00:00)?:00)?\.000Z$/, '')
119+
(value as Date).toISOString().replace(/(T00:00:00)?\.000Z$/, '')
120120
}

tests/doc/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,7 @@ english: null
660660
---
661661
canonical: 2001-12-15T02:59:43.1Z
662662
valid iso8601: 2001-12-14t21:59:43.10-05:00
663+
no secs: 2001-12-15T02:59:00
663664
space separated: 2001-12-14 21:59:43.10 -5
664665
no time zone (Z): 2001-12-15 2:59:43.10
665666
date (00:00:00Z): 2002-12-14`
@@ -671,6 +672,7 @@ date (00:00:00Z): 2002-12-14`
671672
expect(doc.toJSON()).toMatchObject({
672673
canonical: '2001-12-15T02:59:43.100Z',
673674
'valid iso8601': '2001-12-15T02:59:43.100Z',
675+
'no secs': '2001-12-15T02:59:00.000Z',
674676
'space separated': '2001-12-15T02:59:43.100Z',
675677
'no time zone (Z)': '2001-12-15T02:59:43.100Z',
676678
'date (00:00:00Z)': '2002-12-14T00:00:00.000Z'
@@ -679,6 +681,7 @@ date (00:00:00Z): 2002-12-14`
679681
---
680682
canonical: 2001-12-15T02:59:43.100Z
681683
valid iso8601: 2001-12-15T02:59:43.100Z
684+
no secs: 2001-12-15T02:59:00
682685
space separated: 2001-12-15T02:59:43.100Z
683686
no time zone (Z): 2001-12-15T02:59:43.100Z
684687
date (00:00:00Z): 2002-12-14\n`)

0 commit comments

Comments
 (0)