New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support strftime #4565
Comments
Added Area-Library, Triaged labels. |
I'm going to call this a duplicate of 3953, providing internationalization/localization. So right now the equivalent of what you're asking for would be new DateFormat("E").format(new Date.now()); though with the additional cost that you'd need to have done an async initializeDateFormatting('en_US', null) somewhere previously. It has the advantage that the set of skeletons come from ICU and are reasonably well-defined, and that they will adapt to other locales, so if your default locale was something else it would print appropriately for it. But it isn't printf-like, so it doesn't fit into strings quite as easily. Set owner to @alan-knight. |
This comment was originally written by chris.eee...@gmail.com Just to play devil's advocate, the underlying strftime C library is also locale aware. Maybe it's the old C/Perl/Ruby hacker in me, but to get the locale specific abbreviated day of the week, I much prefer: date.strftime('%a'); To: new DateFormat("E").format(date); There is less cluttering up the intent of the code--at least to my eye. Even if strftime is just a wrapper around DateFormat, I would like to see strftime make it into Dart. |
This comment was originally written by gouttonio@gmail.com Then, why keep the date.format('whatever'); As long as the "whatever" part is heavily documented... Consistency with existing languages is important to flatten the learning curve. But evolution towards elegance is important too ! Just my 2 cents. |
I would love to see this opened back up. It's never too late for Dart to start using the same DateTime string formatting syntax that the rest of the world uses. Dart is going against huge ubiquity here. There are good reasons that some things C never die. |
This issue was originally filed by chri...@gmail.com
It would be really nice if Date supported strftime output. For example:
(new Date.now()).strftime("%a") // "Thu"
The most complete list that I know of is from: http://cheat.errtheblog.com/s/strftime/
Printing dates in JavaScript is hard. It would be so nice if it were easy in Dart.
The text was updated successfully, but these errors were encountered: