Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

What is the rationale for forcing the presence of the day of week? It seems plausible that a weekly report, generated every Sunday for the previous week, would have %GW%V as the title. Seems more correct than using %V together with %w at least.


I don't know for certain, but what I would guess is that strptime() without a day-of-week indicator is ambiguous.

strptime() produces a datetime object, which consists of year, month, day, hour, minute, second, microsecond, time zone, fold. If you do something like "2008-12" with format "%Y-%m", strptime() will fill in the remaining arguments with day=1 and all time components set to zero, so what you get is datetime(year=2018, month=12, day=1, hour=0, minute=0, second=0, microsecond=0).

That works because it's unambiguous -- there aren't multiple possible numbering schemes for the day of the month in the strptime() formatting options.

But there are multiple possible numbering schemes for the day of the week, which means a year + week with no day-of-week format code is ambiguous. Worse, the two options don't even share a start: one of them begins numbering at 0 (Sunday) and the other at 1 (Monday).

So I'd guess the insistence on a day-of-week format code is to force you to indicate which day-numbering scheme you want, in order to avoid the possible ambiguity.

(and you might think it's reasonable to assume if someone uses ISO year + ISO week number, they'd also want ISO day-of-week number, but we're talking about dates and times here, and "reasonable" left the building a long time ago)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: