Open jecovier opened 5 years ago
PR welcome
Well, for the examples in the table, I think all you need is:
var options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric', hour: 'numeric', minute: 'numeric', second: 'numeric' };
date.toLocaleDateString('en-US', options);
and
var options = { weekday: 'short', hour: 'numeric'};
date.toLocaleDateString('en-US', options);
You can also put undefined
as the first parameter if you want to be locale
-neutral; would probably be worth a comment
I can make the simple PR, but tests fail because there's a comma difference:
Sunday, September 9, 2018
in native
Sunday, September 9th 2018
in moment
Native also doesn't support nth
@Amorymeltzer feel free to fix the test too.
How about Intl.DateTimeFormat? Performance note as mentioned in the toLocaleDateString mdn page.
Hi, I really like this! thanks for your effort!
I Know it's not exactly the same, but i think you can add toLocaleDateString as an native option for date formatting. More in the link below:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString