Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 17 Dec 2020 11:47:34 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 251918] strptime(): %b always returns month 0
Message-ID:  <bug-251918-227@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D251918

            Bug ID: 251918
           Summary: strptime(): %b always returns month 0
           Product: Base System
           Version: 12.2-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: ian@chard.org

I noticed this when using 'date -f' to convert a date string:

$ date -j -f '%b %j %T %Y %Z' 'Mar 18 12:00:00 2021 GMT'
Mon Jan 18 12:00:00 GMT 2021

Passing this directly to strptime() gives the same results.  If I do

struct tm t;
strptime("Mar 18 12:00:00 2021 GMT", "%b %j %T %Y %Z", &t);

then t.tm_mon is always 0.

If I use an invalid month then strptime() returns NULL, so it is recognising
the month names, just not actually setting the correct month number in the
struct tm.

Tried with a couple of locales (including 'C') with the same results.

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-251918-227>