Dates with Timezones and ISO8601 Date Constants.

Jordan Harband ljharb at gmail.com
Tue Sep 25 01:10:10 UTC 2018


Are you familiar with the Temporal proposal?
https://github.com/tc39/proposal-temporal

On Mon, Sep 24, 2018 at 8:32 PM, J Decker <d3ck0r at gmail.com> wrote:

> I did look back to see other conversations about Dates....
>
> Operating with arbitrary timezones
> https://mail.mozilla.org/pipermail/es-discuss/2016-August/046478.html
>
> Add timezone data to Date
> https://mail.mozilla.org/pipermail/es-discuss/2017-June/048259.html
>
> Even until this moment, Edge/IE cannot parse new Date(
> "2018-09-25T00:17:55.385-07:00").  which makes 50% of the world already
> require a date/time library.
> https://github.com/Microsoft/ChakraCore/issues/5502
> (actually Aug 16 that was closed)
>
> Date.toISOString() only emits 'Z', even though the type itself has the
> offset
>
> as a Date.prototype.toISOLocalString()
> cb : function () {
> var tzo = -this.getTimezoneOffset(),
> dif = tzo >= 0 ? '+' : '-',
> pad = function(num) {
> var norm = Math.floor(Math.abs(num));
> return (norm < 10 ? '0' : '') + norm;
> };
> return this.getFullYear() +
> '-' + pad(this.getMonth() + 1) +
> '-' + pad(this.getDate()) +
> 'T' + pad(this.getHours()) +
> ':' + pad(this.getMinutes()) +
> ':' + pad(this.getSeconds()) +
> dif + pad(tzo / 60) +
> ':' + pad(tzo % 60);
> }
> ----------
> But; that's only semi-accurate, because if I say -07:00 as the offset, I
> don't know if it's MST or PDT (which is knowable I suppose).
>
> There's not a LOT of usage of times in code; but it could be that the
> constant number 2018-09-25T00:26:00.741Z could just BE a Date, similar to
> 123n just being a BigInt.
>
> It would also be handy if there were a builtin ISO w/ Timezone emitter.
>
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20180924/661d7ae6/attachment.html>


More information about the es-discuss mailing list