dayofyear is not great when going into a new year

Chris Angelico rosuav at gmail.com
Tue Jan 5 18:04:56 EST 2021


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.

ChrisA


More information about the Python-list mailing list