Skip to content

Commit 65054e2

Browse files
authored
Merge pull request #34 from mirego/feature/add-support-for-z-to-represent-utc
Add support for “Z” to represent UTC
2 parents d580a94 + b076d9d commit 65054e2

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

fecha.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@
188188
d.isPm = true;
189189
}
190190
}],
191-
ZZ: [/[\+\-]\d\d:?\d\d/, function (d, v) {
191+
ZZ: [/([\+\-]\d\d:?\d\d|Z)/, function (d, v) {
192+
if (v === 'Z') v = '+00:00';
192193
var parts = (v + '').match(/([\+\-]|\d\d)/gi), minutes;
193194

194195
if (parts) {

test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ testParse('milliseconds medium', '10:20:30.12', 'HH:mm:ss.SS', new Date(year, 0,
4646
testParse('milliseconds short', '10:20:30.1', 'HH:mm:ss.S', new Date(year, 0, 1, 10, 20, 30, 100));
4747
testParse('timezone offset', '09:20:31 GMT-0500 (EST)', 'HH:mm:ss ZZ', new Date(Date.UTC(year, 0, 1, 14, 20, 31)));
4848
testParse('UTC timezone offset', '09:20:31 GMT-0000 (UTC)', 'HH:mm:ss ZZ', new Date(Date.UTC(year, 0, 1, 9, 20, 31)));
49+
testParse('UTC timezone offset without explicit offset', '09:20:31 Z', 'HH:mm:ss ZZ', new Date(Date.UTC(year, 0, 1, 9, 20, 31)));
4950
testParse('UTC timezone offset without GMT', '09:20:31 -0000 (UTC)', 'HH:mm:ss ZZ', new Date(Date.UTC(year, 0, 1, 9, 20, 31)));
5051
testParse('invalid date', 'hello', 'HH:mm:ss ZZ', false);
5152
test('i18n month short parse', function() {

0 commit comments

Comments
 (0)