bigeasy / bigeasy/timezone

Formatting years prior to 1000 with %F should produce four digits for year, not three.

Open
#236 0 comments 0 reactions 1 assignee Claimed by @bigeasy View on GitHub
enhancement
Dominant language
JavaScript
Stars
256
Forks
26
PR merge metrics
No merged PRs in 30d

Description

Timezone claims to format dates "with a full implementation of strftime formats, including the GNU date extensions." The [stftime man page](http://man7.org/linux/man-pages/man3/strftime.3.html) describes `%F` as "equivalent to `%Y-%m-%d` (the ISO 8601 date format)." There is, however, ambiguity here when dealing with years prior to 1000. The man page also describes `%Y` as "the year as a decimal number including the century." But [ISO 8601](http://en.wikipedia.org/wiki/ISO_8601#Years) "prescribes, as a minimum, a four-digit year [YYYY]."

I am ambivalent about whether `%Y` should be changed to always include four digits. Some languages (e.g. ruby) treat `%Y` as a `CCYY` value even for single digit centuries, others as variable width; in python, a century less than 1000 is raised as an error. I believe it is appropriate to see "May 1, 900" as the output for the format string `%b %-e, %Y` on a date of `0900-05-01`, but would already see "May 1, 0900" from ruby anyways.

However, I believe if `%Y` remains variable width, `%F`'s ambiguity should be resolved in the direction of conforming to ISO 8601 rather than conforming to equivalence with `%Y-%m-%d`. `%F` is primarily used as a machine-oriented format string (particularly when generating ISO 8601 strings). Without an ISO 8601 compliant `%F`, there is no format string that can be provided to produce an ISO 8601 output.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.