Intl.DateTimeFormat custom pattern output
I want to use Intl.DateTimeFormat https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat but with custom pattern for output. I use this method for php version of ICU dateformat and it's work well. $fmt = datefmt_create( 'fa_IR@calendar=persian', IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'Asia/Tehran', IntlDateFormatter::TRADITIONAL, ' d HH:mm' // as ISO_8601); echo datefmt_format($fmt, time()) . \n;// پنجشنبه ۱۰ اردیبهشت ۱۳۹۴ ۱۲:۱۲ How can i set pattern as ICU documentation in Intl.DateTimeFormat like php version of Intl/ICU date time formatter. My javascript code console.log(new Intl.DateTimeFormat('fa-IR-u-ca-persian').format(new Date())); // ۱۳۹۴/۵/۲۵ ه.ش. How can iset ISO_8601 pattern in my javascript format pattern like d HH:mm or MM yy dd or etc ? ISO_8601 http://en.wikipedia.org/wiki/ISO_8601 PHP IntlDateFormatter::format http://php.net/manual/en/intldateformatter.format.php ICU Date formatter http://www.icu-project.org/apiref/icu4c/udat_8h.html#details ICU Date formats http://www.icu-project.org/apiref/icu4c/classSimpleDateFormat.html#details ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: Proposal for a null coalescing operator
In JS it seems it'd be more useful if it worked with undefined not null. Thanks, Michael McGlothlin Sent from my iPhone On Aug 16, 2015, at 7:33 PM, Brandon Andrews warcraftthre...@sbcglobal.net wrote: https://en.wikipedia.org/wiki/Null_coalescing_operator Essentially x ?? y will return x when not null or undefined else it will return y. A nice Javascript explanation of the current problems with using || that can cause unforeseen bugs: http://stackoverflow.com/a/476445 ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Proposal for a null coalescing operator
https://en.wikipedia.org/wiki/Null_coalescing_operator Essentially x ?? y will return x when not null or undefined else it will return y. A nice Javascript explanation of the current problems with using || that can cause unforeseen bugs: http://stackoverflow.com/a/476445 ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: Proposal for a null coalescing operator
This is something I frequently make a helper function out of. ```js function d(argument, default_) { return argument != null ? argument : default_ } ``` On Sun, Aug 16, 2015, 20:34 Brandon Andrews warcraftthre...@sbcglobal.net wrote: https://en.wikipedia.org/wiki/Null_coalescing_operator Essentially x ?? y will return x when not null or undefined else it will return y. A nice Javascript explanation of the current problems with using || that can cause unforeseen bugs: http://stackoverflow.com/a/476445 ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: Proposal for a null coalescing operator
A link to a wikipedia article is not *actually* a proposal : ) As Michael points out, you need to at least provide some consideration for null vs. undefined. I would also like to see some thought given to how such an operator might interact with a null propagation operator, discussed here: https://esdiscuss.org/topic/existential-operator-null-propagation-operator (Link appears to be temporarily not working...) ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: Intl.DateTimeFormat custom pattern output
Intl.DateTimeFormat doesn’t currently let you specify a custom pattern in ICU/CLDR format. The reason is that the API had to be implemented on top of different existing internationalization APIs, and the API on Windows didn’t support CLDR date format patterns. There is a feature request for patterns and skeletons in DateTimeFormat – I don’t know if the current Internationalization ad-hoc is planning to take it up: https://bugs.ecmascript.org/show_bug.cgi?id=771 You can get an ISO 8601-style date format directly from Date.prototype.toISOString, but that uses the Gregorian calendar and UTC; it cannot be configured to use the Persian calendar or Iran time. Norbert On Aug 16, 2015, at 10:45 , Muhammad Hussein Fattahizadeh semnan...@gmail.com wrote: I want to use Intl.DateTimeFormat but with custom pattern for output. I use this method for php version of ICU dateformat and it's work well. $fmt = datefmt_create( 'fa_IR@calendar=persian', IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'Asia/Tehran', IntlDateFormatter::TRADITIONAL, ' d HH:mm' // as ISO_8601 ); echo datefmt_format ($fmt, time()) . \n; // پنجشنبه ۱۰ اردیبهشت ۱۳۹۴ ۱۲:۱۲ How can i set pattern as ICU documentation in Intl.DateTimeFormat like php version of Intl/ICU date time formatter. My javascript code console.log(new Intl.DateTimeFormat('fa-IR-u-ca-persian').format(new Date())); // ۱۳۹۴/۵/۲۵ ه.ش. How can iset ISO_8601 pattern in my javascript format pattern like d HH:mm or MM yy dd or etc ? ISO_8601 PHP IntlDateFormatter::format ICU Date formatter ICU Date formats ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
`null` and default arguments
I know it's a little late for this, but what was the rationale of using only `undefined` instead of both that and `null` to denote omitted values for optional arguments in ES6? Before this change, it was a frequent idiom to check optional arguments via `== null` instead of `=== undefined` and pass `null` as the argument to denote the absence of a value. Just a curious question. ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss