diff --git a/src/components/datetime/test/basic/index.ts b/src/components/datetime/test/basic/index.ts index e3fdc729e65..8ce2e63bc58 100644 --- a/src/components/datetime/test/basic/index.ts +++ b/src/components/datetime/test/basic/index.ts @@ -14,6 +14,7 @@ class E2EPage { webkitOpenSourced = '2005-06-17T11:06Z'; chromeReleased = '2008-09-02'; leapYearsSummerMonths = ''; + convertedDate = ''; leapYearsArray = [2020, 2016, 2008, 2004, 2000, 1996]; @@ -39,6 +40,10 @@ class E2EPage { this.leapYearsSummerMonths = null; } + convertDate() { + this.convertedDate = new Date(this.myDate).toISOString(); + } + } diff --git a/src/components/datetime/test/basic/main.html b/src/components/datetime/test/basic/main.html index bda450e2e8b..85efaa43371 100644 --- a/src/components/datetime/test/basic/main.html +++ b/src/components/datetime/test/basic/main.html @@ -68,6 +68,18 @@ Leap year, summer months: {{leapYearsSummerMonths}}

- +

+ +

+ + + myDate: {{myDate}} + + + +

+ + {{convertedDate}} +

diff --git a/src/util/datetime-util.ts b/src/util/datetime-util.ts index bf43273c76c..2b72608aed8 100644 --- a/src/util/datetime-util.ts +++ b/src/util/datetime-util.ts @@ -352,7 +352,7 @@ export function convertDataToISO(data: DateTimeData): string { rtn += '.' + threeDigit(data.millisecond); } - if (data.tzOffset === 0) { + if (isBlank(data.tzOffset) || data.tzOffset === 0) { // YYYY-MM-DDTHH:mm:SSZ rtn += 'Z'; diff --git a/src/util/test/datetime-util.spec.ts b/src/util/test/datetime-util.spec.ts index 409a656e850..7e9700a6803 100644 --- a/src/util/test/datetime-util.spec.ts +++ b/src/util/test/datetime-util.spec.ts @@ -4,6 +4,20 @@ export function run() { describe('convertDataToISO', () => { + it('should convert DateTimeData to datetime string, with blank timezone', () => { + var data: datetime.DateTimeData = { + year: 1994, + month: 12, + day: 15, + hour: 13, + minute: 47, + second: 20, + }; + + var str = datetime.convertDataToISO(data); + expect(str).toEqual('1994-12-15T13:47:20Z'); + }); + it('should convert DateTimeData to datetime string, +330 tz offset', () => { var data: datetime.DateTimeData = { year: 1994,