From 739f9bc0d9af4fd658d393b9b52230a665217561 Mon Sep 17 00:00:00 2001 From: Iskren Chernev Date: Wed, 2 Apr 2014 00:22:44 -0700 Subject: [PATCH] Fix iso parsing with more than 3 subsecond digits --- moment.js | 2 +- test/moment/create.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/moment.js b/moment.js index b059e0a82..cd6f2add2 100644 --- a/moment.js +++ b/moment.js @@ -91,7 +91,7 @@ // iso time formats and regexes isoTimes = [ - ['HH:mm:ss.SSSS', /(T| )\d\d:\d\d:\d\d\.\d{1,3}/], + ['HH:mm:ss.SSSS', /(T| )\d\d:\d\d:\d\d\.\d+/], ['HH:mm:ss', /(T| )\d\d:\d\d:\d\d/], ['HH:mm', /(T| )\d\d:\d\d/], ['HH', /(T| )\d\d/] diff --git a/test/moment/create.js b/test/moment/create.js index c0a3a606c..185ef9494 100644 --- a/test/moment/create.js +++ b/test/moment/create.js @@ -600,6 +600,12 @@ exports.create = { test.done(); }, + "parsing iso with more subsecond precision digits" : function (test) { + test.equal(moment.utc("2013-07-31T22:00:00.0000000Z").format(), + "2013-07-31T22:00:00+00:00", "more than 3 subsecond digits"); + test.done(); + }, + "null or empty" : function (test) { test.expect(8); test.equal(moment('').isValid(), false, "moment('') is not valid"); -- 2.47.2