7 ms·
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 wa
by protomyth 5y ago
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?
- yholio 5y agoPresumably 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
- easbar 5y ago> 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.
- deleted 5y ago[deleted]
- karussell 5y agoYes! 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)
- protomyth 5y agoOk, 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.
- LinAGKar 5y agoShouldn't it be the other way around? The first days of 2022 were in week 52 of 2021
- throw0101a 5y ago> 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 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 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 https://en.wikipedia.org/wiki/ISO_week_date#First_week
- protomyth 5y agoNice explanation but I directly quoted the article. Karussell provided an explanation at https://news.ycombinator.com/item?id=29794778 https://news.ycombinator.com/item?id=29794778
- masklinn 5y ago> 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.
- masklinn 5y ago> 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.