Bug 29460 - strptime() doesn't support strftime() %P format
Summary: strptime() doesn't support strftime() %P format
Status: UNCONFIRMED
Alias: None
Product: glibc
Classification: Unclassified
Component: time (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-08-08 19:21 UTC by Yann Droneaud
Modified: 2022-08-08 19:58 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
strftime(), strptime() %P format test (406 bytes, text/x-csrc)
2022-08-08 19:21 UTC, Yann Droneaud
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Yann Droneaud 2022-08-08 19:21:30 UTC
Created attachment 14266 [details]
strftime(), strptime() %P format test

Despite being documented as supported alias to %p, %P is not known to strptime()

https://www.gnu.org/software/libc/manual/html_node/Low_002dLevel-Time-String-Parsing.html

> %p
> %P
> 
>     The locale-dependent equivalent to ‘AM’ or ‘PM’.
> 
>     This format is not useful unless %I or %l is also used. Another complication is that the locale might not define these values at all and therefore the conversion fails.
> 
>     %P is a GNU extension following a GNU extension to strftime.

https://man7.org/linux/man-pages/man3/strptime.3.html

>     Similarly, because of GNU extensions to strftime(3), %k is
>     accepted as a synonym for %H, and %l should be accepted as a
>     synonym for %I, and %P is accepted as a synonym for %p.

The attached test case produced the following output:

    strftime() produced "am"
    strptime() failed to parse "am"
    strftime() produced "pm"
    strptime() failed to parse "pm"


Fixes for https://sourceware.org/bugzilla/show_bug.cgi?id=4772 is incomplete.