From 272daf299334f42f781ee595f04e6e6cc06c775c Mon Sep 17 00:00:00 2001
From: Adam Bradley
Date: Wed, 1 Jun 2016 09:40:45 -0500
Subject: [PATCH] fix(datetime): fix ISO format when w/out timezone data
Closes #6608
---
src/components/datetime/test/basic/index.ts | 5 +++++
src/components/datetime/test/basic/main.html | 14 +++++++++++++-
src/util/datetime-util.ts | 2 +-
src/util/test/datetime-util.spec.ts | 14 ++++++++++++++
4 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/src/components/datetime/test/basic/index.ts b/src/components/datetime/test/basic/index.ts
index e3fdc729e6..8ce2e63bc5 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 bda450e2e8..85efaa4337 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 bf43273c76..2b72608aed 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 409a656e85..7e9700a680 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,