Skip to content

Commit 95c7cea

Browse files
committed
Support for ZZ token
1 parent 3cd6f43 commit 95c7cea

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/factory.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ angular.module("datetime").factory("datetime", function($locale){
22
// Fetch date and time formats from $locale service
33
var formats = $locale.DATETIME_FORMATS;
44
// Valid format tokens. 1=sss, 2=''
5-
var tokenRE = /yyyy|yy|y|M{1,4}|dd?|EEEE?|HH?|hh?|mm?|ss?|([.,])sss|a|Z|ww|w|'(([^']+|'')*)'/g;
5+
var tokenRE = /yyyy|yy|y|M{1,4}|dd?|EEEE?|HH?|hh?|mm?|ss?|([.,])sss|a|Z{1,2}|ww|w|'(([^']+|'')*)'/g;
66
// Token definition
77
var definedTokens = {
88
"y": {
@@ -184,6 +184,11 @@ angular.module("datetime").factory("datetime", function($locale){
184184
type: "regex",
185185
regex: /[+-]\d{4}/
186186
},
187+
"ZZ": {
188+
name: "timezoneWithColon",
189+
type: "regex",
190+
regex: /[+-]\d{2}:\d{2}/
191+
},
187192
"string": {
188193
name: "string",
189194
type: "static"
@@ -339,6 +344,9 @@ angular.module("datetime").factory("datetime", function($locale){
339344
case "timezone":
340345
node.value = (date.getTimezoneOffset() > 0 ? "-" : "+") + num2str(Math.abs(date.getTimezoneOffset() / 60), 2, 2) + "00";
341346
break;
347+
case "timezoneWithColon":
348+
node.value = (date.getTimezoneOffset() > 0 ? "-" : "+") + num2str(Math.abs(date.getTimezoneOffset() / 60), 2, 2) + ":00";
349+
break;
342350
}
343351

344352
if (node.value < 0) {

0 commit comments

Comments
 (0)