mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Petr Pisar <petr.pisar@atlas.cz>
To: musl@lists.openwall.com
Subject: Re: [musl] strptime(s, "%Y-%j", &tm) does not update month and day
Date: Sun, 12 May 2024 09:54:13 +0200	[thread overview]
Message-ID: <ZkB1pX8wTRe-4lhV@album.bayer.uni.cx> (raw)
In-Reply-To: <20240511212853.GS10433@brightrain.aerifal.cx>

[-- Attachment #1: Type: text/plain, Size: 1351 bytes --]

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
> > <https://bugs.gentoo.org/show_bug.cgi?id=928107>, 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 https://austingroupbugs.net/view.php?id=1727 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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2024-05-12  7:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-11 15:24 Petr Pisar
2024-05-11 21:28 ` Rich Felker
2024-05-12  7:54   ` Petr Pisar [this message]
2024-05-13 12:18     ` Rich Felker
2024-05-13 21:18       ` Thorsten Glaser

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZkB1pX8wTRe-4lhV@album.bayer.uni.cx \
    --to=petr.pisar@atlas.cz \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).