2 ms·
> What do you propose instead? What if the format codes were just a bit less cryptic? Short words, for each field, optionally qualified to select unusual varia
by twic 9y ago
> What do you propose instead?
What if the format codes were just a bit less cryptic? Short words, for each field, optionally qualified to select unusual variants
%{year}-%{month}-%{dayOfMonth} %{hour}-%{min}-%{sec} %{tz:name}
Year is four digits, unless you ask for %{year:2digit}. If you want the crazy week-year, that's %{year:byweek}. Where things could plausibly be textual or numeric, the default is numeric. So %{month} is the month number, and %{month:name} is the month name; %{tz} is the timezone offset, and %{tz:name} is its symbolic name (a can of worms, i know). %{dayOfMonth} and %{dayOfWeek} are both a bit verbose because neither one is more obviously %{day} (so that goes unused), but you can abbreviate them to %{dom} and %{dow}. %{hour} is 24-hour, but you can have %{hour:12h}.
> No. Learn the details of your programming language, libraries and frameworks. Even their gotchas.
Yes, but also, let's reduce gotchas in the design of our programming languages, libraries, and frameworks. It's pathetic that we're still using strftime as our default option in 2018.
- userbinator 9y agoMaking things horribly verbose (and thus prone to typos, introducing extra complexity in implementation, etc.) is a poor excuse for actually learning how something works so you can use it effectively and efficiently. The most common cases of strftime() are highly mnemonic, so much that seeing "%G %m %d" instead of the more common and correct "%Y %m %d" should make you wonder if it was really intended. but also, let's reduce gotchas in the design %Y being the correct format to use most of the time is not a "gotcha". If the roles of %G and %Y were reversed I would agree.