Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sun, 12 May 2024 09:54:13 +0200
From: Petr Pisar <>
Subject: Re: strptime(s, "%Y-%j", &tm) does not update month and day

V Sat, May 11, 2024 at 05:28:54PM -0400, Rich Felker napsal(a):
> On Sat, May 11, 2024 at 05:24:59PM +0200, Petr Pisar wrote:
> > Hello,
> > 
> > When debugging a libisds test failure with musl-1.2.5
> > <>, I found that musl's
> > strptime() does not handle "%Y-%j" properly. It accepts the format, it parses
> > the input string, it returns a correct pointer past the input string, but it
> > does not update tm.tm_mon and tm.tm_mday fileds of the third argument.
> This is behaving as specified. Previously, the behavior was
> unspecified. POSIX has amended it for future issues as the resolution
> of to read:
>     The tm_yday member of the tm structure pointed to by tm shall be
>     set to this number minus 1.
> strptime generally does not behave like mktime, doing
> normalizations/conversions.
I see. I thought that strptime() does the normalization. Reading
mktime() specification reveals it has a side effect of normalizing tm_yday
from tm_year, tm_mon, and tm_mday.

However, I need the oposite and I cannot find any standard library function
for that. I will probaly resort to my own implementation with the drawback
of assumption that rules for leap years in Gregorian calendar won't change.

-- Petr

Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.