News for hackers. Stuff that matters.
Re:Do not use 'week year': YYYY by protomyth on Tuesday January 04, 2022 @08:05AM (#29794257)
I understand that "week year" is basically a payroll creation, but I am a bit concerned about the last few days of 2021 were logged as 2022, and Jan 1st 2022 was even logged as 2023.

The last few days of 2021 logged as 2022 makes sense for payroll, but how the heck is Jan 1st 2022 put in the 2023 year?

Re:Do not use 'week year': YYYY by throw0101a on Tuesday January 04, 2022 @08:43AM (#29794595)
> The last few days of 2021 logged as 2022 makes sense for payroll, but how the heck is Jan 1st 2022 put in the 2023 year?

First off, I think you have a typo(?) with the "2023"? Because:

* https://www.epochconverter.com/weeks/2022

The reason(s) why the week system was designed:

> * All weeks have exactly 7 days, i.e. there are no fractional weeks.

> * Every week belongs to a single year, i.e. there are no ambiguous or double-assigned weeks.

> * The date directly tells the weekday.

> * All week-numbering years start with a Monday and end with a Sunday.

> * When used by itself without using the concept of month, all week-numbering years are the same except that some years have a week 53 at the end.

* https://en.wikipedia.org/wiki/ISO_week_date#Advantages

This makes perfect sense if your role is in bookkeeping / accounting / finance. Your life is based on pay periods and not on day-of-year/month. A particular pay day "belonging" to a particular year is a meaningless affectation: people need to get paid every two weeks come hell or high water, and anything that can complicate the smooth running of that process is discarded.

As for the algorithm:

> The ISO 8601 definition for week 01 is the week with the first Thursday of the Gregorian year (i.e. of January) in it. The following definitions based on properties of this week are mutually equivalent, since the ISO week starts with Monday: […]

* https://en.wikipedia.org/wiki/ISO_week_date#First_week

Re:Do not use 'week year': YYYY by protomyth on Tuesday January 04, 2022 @09:13AM (#29794922)
Nice explanation but I directly quoted the article. Karussell provided an explanation at https://news.ycombinator.com/item?id=29794778
Re:Do not use 'week year': YYYY by masklinn on Tuesday January 04, 2022 @11:14AM (#29796420)
> This makes perfect sense if your role is in bookkeeping / accounting / finance. Your life is based on pay periods and not on day-of-year/month. A particular pay day "belonging" to a particular year is a meaningless affectation: people need to get paid every two weeks come hell or high water, and anything that can complicate the smooth running of that process is discarded.

It's not just payrolls, it's also things like deliveries or synchronisation. And saying "monday week 15" (or writing "W15 mon") aside from being short and precise can give a better ground for synchronisation or collision than "April 11th" e.g. the person you're talking to might know that every monday would be an issue and be able to say that that's not an option before even looking it up.

Re:Do not use 'week year': YYYY by masklinn on Tuesday January 04, 2022 @09:48AM (#29795302)
> I understand that "week year" is basically a payroll creation

It's not, it's a fiscal, or more generally business creation, allowing businesses to express everything in weekly basis, with no variance (all weeks are 7 days mon-sun with no fractionals, and every week belongs to a single year with no ambiguity).

This is very, very common usage in european businesses, and even casual settings, to the extent that you'll have a hard time finding a physical calendar without weeks printed on it.

Re:Do not use 'week year': YYYY by easbar on Tuesday January 04, 2022 @08:23AM (#29794402)
> but how the heck is Jan 1st 2022 put in the 2023 year?

This only happened shortly after midnight on January 1st. So I guess this is somehow related to different time zones/offsets.

Re:Do not use 'week year': YYYY by karussell on Tuesday January 04, 2022 @08:59AM (#29794778)
Yes! I just looked into it and the log itself was still 2022:

2022-12-31 23:16:54.013

And then our UI converted this entry into one with 2023

(it correctly assumes that the string is in UTC and then converted it to local time +1h)

Re:Do not use 'week year': YYYY by protomyth on Tuesday January 04, 2022 @09:10AM (#29794897)
Ok, you had me a bit worried on that one.

A linter should probably flag any format that mixes "week year" with month and days. It's really for use by itself or with payroll week number.

Re:Do not use 'week year': YYYY by yholio on Tuesday January 04, 2022 @08:13AM (#29794319)
Presumably with a code path similar to this:

  get date as (week year, month, day)
  add start_interval to date using regular time handling functions
  print "task scheduled to start on: ", date
When you run this code on 31 December 2021 and schedule the task to run 1 day later, you will see 2023 in the logs
Re:Do not use 'week year': YYYY by LinAGKar on Tuesday January 04, 2022 @08:41AM (#29794570)
Shouldn't it be the other way around? The first days of 2022 were in week 52 of 2021