Skip to content

Commit

Permalink
fix(): Built-in date type uses local time zone
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherthielen committed Nov 21, 2014
1 parent b267ecd commit d726bed
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/urlMatcherFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,6 @@ function $UrlMatcherFactory() {

function valToString(val) { return val != null ? val.toString().replace(/\//g, "%2F") : val; }
function valFromString(val) { return val != null ? val.toString().replace(/%2F/g, "/") : val; }
function angularEquals(left, right) { return angular.equals(left, right); }
// TODO: in 1.0, make string .is() return false if value is undefined by default.
// function regexpMatches(val) { /*jshint validthis:true */ return isDefined(val) && this.pattern.test(val); }
function regexpMatches(val) { /*jshint validthis:true */ return this.pattern.test(val); }
Expand All @@ -588,16 +587,22 @@ function $UrlMatcherFactory() {
pattern: /0|1/
},
date: {
encode: function (val) { return [
encode: function (val) {
return [
val.getFullYear(),
('0' + (val.getMonth() + 1)).slice(-2),
('0' + val.getDate()).slice(-2)
].join("-");
},
decode: function (val) { return new Date(val); },
decode: function (val) {
if (this.is(val)) return val;
var match = this.capture.exec(val);
return match ? new Date(match[1], match[2] - 1, match[3]) : undefined;
},
is: function(val) { return val instanceof Date && !isNaN(val.valueOf()); },
equals: function (a, b) { return a.toISOString() === b.toISOString(); },
pattern: /[0-9]{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[1-2][0-9]|3[0-1])/
pattern: /[0-9]{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[1-2][0-9]|3[0-1])/,
capture: /([0-9]{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])/
}
};

Expand Down

0 comments on commit d726bed

Please sign in to comment.