dayofyear is not great when going into a new year

Mats Wichmann mats at wichmann.us
Tue Jan 5 20:02:41 EST 2021


On 1/5/21 4:04 PM, Chris Angelico wrote:
> On Wed, Jan 6, 2021 at 10:01 AM Eli the Bearded <*@eli.users.panix.com> wrote:
>>
>> In comp.lang.python, Chris Angelico  <rosuav at gmail.com> wrote:
>>> There are multiple definitions for "day of year", depending on how you
>>> want to handle certain oddities. The simplest is to identify Jan 1st
>>> as 1, Jan 2nd as 2, etc, to Dec 31st as either 365 or 366; but some
>>> libraries will define the year as starting with the week that contains
>>> the Thursday, or something, and then will define days of year
>>> accordingly.
>>
>> That sounds like some weird off-shoot of the ISO-8601 calendar. That
>> document primarily concerns itself with weeks. Week 1 of a year is the
>> first week with a Thursday in it. The last week of a year will be either
>> 52 or 53, and you can have things like days in January belonging to the
>> week of the previous year.
> 
> The "weird off-shoot" part is probably a result of me misremembering
> things, so don't read too much into the details :) I just remember
> coming across something that numbered days within a year in a way that
> was consistent with the way that it numbered weeks, which would indeed
> have been based on the ISO 8601 week numbering. Not 100% sure of the
> exact details.

"workweeks" has always been fun, ISO standard or not, there's been a 
variation for ages since people don't seem to always follow ISO for 
that.  I spent over a decade at a place that lived and died by their 
WorkWeek references ("due WW22" or the like would appear in every status 
report ever written, and there were zillions of those) - and it didn't 
agree with ISO on whether WW1 was the week that contained Jan 1 or 
whether it was the week that followed the previous year's last workweek. 
After all, those few days can't actually belong to two different 
workweeks, now can they?  :)

(that was not a good memory you guys brought back :) )


More information about the Python-list mailing list