Closed mattjohnsonpint closed 11 years ago
That seems like a reasonable expectation. I'll try to fix this up and get an update out soon.
Actually, according to the MDN docs on Date.toISOString() it should always give the UTC string with a Z on the end. But, since we don't do that currently I'll still be fixing it up.
Now published as version 0.0.16 to npm, and updated in source.
I think this is one place you should break with the MDN specs. After all, a WallTime is not the same as a Date, so it shouldn't have to match exactly. ISO8601 dates allow either format, and so does the stricter RFC3339.
Since the intent of the library is to help with areas that aren't handled by Date, I would request that you please provide the form with the offset, rather than the Z. If someone wants the UTC timestamp, they can always go back to the underlying Date object to get it.
If, on the other hand, you prefer strict adherence to the behavior of Date, then would you please add a separate method to get the other form? perhaps toISOStringWithOffset()
or similar.
I'm not going to do that. But, you are free to extend the prototype of WallTime.TimeZoneTime
on your own. Ideally, that is something that a formatting library sitting on top of WallTime can provide.
Ok. Thanks.
If you are interested, here is the function I use:
WallTime.TimeZoneTime.prototype.toISOStringWithOffset = function() {
var o = this.getTimezoneOffset();
var hh = Math.abs(o / 60);
var mm = Math.abs(o % 60);
if (hh < 10) hh = '0' + hh;
if (mm < 10) mm = '0' + mm;
var sign = o > 0 ? '-' : '+'; // invert for iso
var offset = sign + hh + ':' + mm;
return this.wallTime.toISOString().slice(0, -1) + offset;
};
Feel free to add it if you want.
Since these represent the same moment, shouldn't the walltime output the offset instead of the Z?
I would expect:
2013-06-09T20:00:00.000-04:00