Skip to content
Browse files

Make tz info optional in ISO8601 format

  • Loading branch information...
1 parent 3a5288d commit 0bd4127cddeb6146248c7badbf02c3d1a4e4a3dc @mde committed Oct 21, 2013
Showing with 16 additions and 12 deletions.
  1. +16 −12 lib/date.js
View
28 lib/date.js
@@ -865,20 +865,24 @@ date = new (function () {
, str = this.strftime(dt, '%F') + 'T'
+ this.strftime(dt, '%T') + '.'
+ string.lpad(dt.getMilliseconds(), '0', 3);
- // Pos and neg numbers are both truthy; only
- // zero is falsy
- if (off && !opts.utc) {
- str += off > 0 ? '-' : '+';
- offHours = parseInt(off / 60, 10);
- str += string.lpad(offHours, '0', 2);
- offMinutes = off % 60;
- if (offMinutes) {
- str += string.lpad(offMinutes, '0', 2);
+
+ if (opts.tz) {
+ // Pos and neg numbers are both truthy; only
+ // zero is falsy
+ if (off && !opts.utc) {
+ str += off > 0 ? '-' : '+';
+ offHours = parseInt(off / 60, 10);
+ str += string.lpad(offHours, '0', 2);
+ offMinutes = off % 60;
+ if (offMinutes) {
+ str += string.lpad(offMinutes, '0', 2);
+ }
+ }
+ else {
+ str += 'Z';
}
}
- else {
- str += 'Z';
- }
+
return str;
};

0 comments on commit 0bd4127

Please sign in to comment.
Something went wrong with that request. Please try again.