diff --git a/src/schema/yaml-1.1/timestamp.ts b/src/schema/yaml-1.1/timestamp.ts index 2093f3ae..2cdc79bc 100644 --- a/src/schema/yaml-1.1/timestamp.ts +++ b/src/schema/yaml-1.1/timestamp.ts @@ -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$/, '') } diff --git a/tests/doc/types.ts b/tests/doc/types.ts index 31658aa3..bd3c0667 100644 --- a/tests/doc/types.ts +++ b/tests/doc/types.ts @@ -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` @@ -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' @@ -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`)