Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make tz info optional in ISO8601 format
  • Loading branch information
mde committed Oct 21, 2013
1 parent 3a5288d commit 0bd4127
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions lib/date.js
Expand Up @@ -865,20 +865,24 @@ date = new (function () {
, str = this.strftime(dt, '%F') + 'T' , str = this.strftime(dt, '%F') + 'T'
+ this.strftime(dt, '%T') + '.' + this.strftime(dt, '%T') + '.'
+ string.lpad(dt.getMilliseconds(), '0', 3); + string.lpad(dt.getMilliseconds(), '0', 3);
// Pos and neg numbers are both truthy; only
// zero is falsy if (opts.tz) {
if (off && !opts.utc) { // Pos and neg numbers are both truthy; only
str += off > 0 ? '-' : '+'; // zero is falsy
offHours = parseInt(off / 60, 10); if (off && !opts.utc) {
str += string.lpad(offHours, '0', 2); str += off > 0 ? '-' : '+';
offMinutes = off % 60; offHours = parseInt(off / 60, 10);
if (offMinutes) { str += string.lpad(offHours, '0', 2);
str += string.lpad(offMinutes, '0', 2); offMinutes = off % 60;
if (offMinutes) {
str += string.lpad(offMinutes, '0', 2);
}
}
else {
str += 'Z';
} }
} }
else {
str += 'Z';
}
return str; return str;
}; };


Expand Down

0 comments on commit 0bd4127

Please sign in to comment.