
Unicode date formats, YYYY? - ingve
http://boredzo.org/blog/archives/2015-10-24/the-international-standards-organization-hates-your-guts
======
Aloisius
If you're curious about ISO week dates, there is a nice Wikipedia article on
it that explains what is going on a little more clearly.

[https://en.wikipedia.org/wiki/ISO_week_date](https://en.wikipedia.org/wiki/ISO_week_date)

------
p1mrx
WTF, who designed that format? That's like having a gun where the muzzle
points backwards if you forget a step assembling it.

~~~
simoncion
Two things:

* As rdancer mentions, you must _always_ fully understand printf-style format options before you use them. To do otherwise invites disaster.

* What would you have chosen for the four-digit-calendar-year format specifier and the four-digit-week-of-year format specifier?

Edit: Notice also that you can add more "y" or "Y" characters to get greater
precision, so the existing format specifiers _already_ solve the Y10K problem.

~~~
krick
I agree with everything you said and don't think this format is bad at all,
but regarding your "Y10K problem" note, I actually prefer PHP date format,
that is "Y/y" instead of "yyyy/yy".

First of, I'm sure you need year far more often than "week year", so the less
intuitive encoding for the latter is acceptable and I have to admit that
confusing letter case is pretty easy when the result is identical for most of
the time (so simple "run it, see if it works" won't help, and that's exactly
how everybody does programming).

Second, I don't imagine I'll ever want to display last three symbols of the
year instead of the full year, and I most of the time don't want to get "0476"
instead of "476" — and if I do, I'm actually OK with post-processing for these
special occasions. The only thing I actually want is _full_ year format
(whatever long it is) or, rarely, _short_ (2-letter) year format (which I
actually think is stupid and never use it except somebody specifically asks me
to). So while I'm absolutely clear with what "Y/y" does, I have no idea what
'yyy' would do for 4-digit long year or what 'yyyy' would do for 3 or 5 digit
long year for that matter.

------
mappu
Unicode date formats can be used in PHP via `ext/intl`, the ICU wrapper
library;

    
    
        $ php -r 'date_default_timezone_set("Etc/UTC"); $x = new IntlDateFormatter("en_GB", 0, 0); $x->setPattern("yyyy"); echo $x->format(time());'

