From 5624c7d5457a545879feafbd45fe2c2adba10ed7 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Mon, 21 Mar 2016 13:04:59 -0700 Subject: [PATCH 1/2] [Time Formats] Display UTC with milliseconds #776 --- platform/commonUI/formats/src/UTCTimeFormat.js | 3 ++- platform/commonUI/formats/test/UTCTimeFormatSpec.js | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/platform/commonUI/formats/src/UTCTimeFormat.js b/platform/commonUI/formats/src/UTCTimeFormat.js index b035fed99f..d2d96f6578 100644 --- a/platform/commonUI/formats/src/UTCTimeFormat.js +++ b/platform/commonUI/formats/src/UTCTimeFormat.js @@ -28,9 +28,10 @@ define([ ) { "use strict"; - var DATE_FORMAT = "YYYY-MM-DD HH:mm:ss", + var DATE_FORMAT = "YYYY-MM-DD HH:mm:ss.SSSZ", DATE_FORMATS = [ DATE_FORMAT, + "YYYY-MM-DD HH:mm:ss", "YYYY-MM-DD HH:mm", "YYYY-MM-DD" ]; diff --git a/platform/commonUI/formats/test/UTCTimeFormatSpec.js b/platform/commonUI/formats/test/UTCTimeFormatSpec.js index d55a8a9507..f8bda55b30 100644 --- a/platform/commonUI/formats/test/UTCTimeFormatSpec.js +++ b/platform/commonUI/formats/test/UTCTimeFormatSpec.js @@ -40,6 +40,12 @@ define( expect(moment.utc(formatted).valueOf()).toEqual(timestamp); }); + it("displays with millisecond precision", function () { + var timestamp = 12345670789, + formatted = format.format(timestamp); + expect(moment.utc(formatted).valueOf()).toEqual(timestamp); + }); + it("validates time inputs", function () { expect(format.validate("1977-05-25 11:21:22")).toBe(true); expect(format.validate("garbage text")).toBe(false); From a411bac3314bde57863755c3e6dc266eb273a776 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Mon, 21 Mar 2016 14:29:24 -0700 Subject: [PATCH 2/2] [Time Format] Append Z instead of zone offset ...for brevity (reduce visual noise) --- platform/commonUI/formats/src/UTCTimeFormat.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/commonUI/formats/src/UTCTimeFormat.js b/platform/commonUI/formats/src/UTCTimeFormat.js index d2d96f6578..3d216f8ff5 100644 --- a/platform/commonUI/formats/src/UTCTimeFormat.js +++ b/platform/commonUI/formats/src/UTCTimeFormat.js @@ -28,7 +28,7 @@ define([ ) { "use strict"; - var DATE_FORMAT = "YYYY-MM-DD HH:mm:ss.SSSZ", + var DATE_FORMAT = "YYYY-MM-DD HH:mm:ss.SSS", DATE_FORMATS = [ DATE_FORMAT, "YYYY-MM-DD HH:mm:ss", @@ -49,7 +49,7 @@ define([ } UTCTimeFormat.prototype.format = function (value) { - return moment.utc(value).format(DATE_FORMAT); + return moment.utc(value).format(DATE_FORMAT) + "Z"; }; UTCTimeFormat.prototype.parse = function (text) {