* [PATCH] strptime: fix am/pm converting to 24-hour system
@ 2024-02-20 18:51 Alexey Lapshin
2024-02-21 14:53 ` Corinna Vinschen
0 siblings, 1 reply; 2+ messages in thread
From: Alexey Lapshin @ 2024-02-20 18:51 UTC (permalink / raw)
To: newlib; +Cc: Alexey Gerenkov, Ivan Grokhotkov
Fix the issue of parsing 08:00AM, which currently gives a 20:00 representation.
---
newlib/libc/time/strptime.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/newlib/libc/time/strptime.c b/newlib/libc/time/strptime.c
index 6220ff73a..188218059 100644
--- a/newlib/libc/time/strptime.c
+++ b/newlib/libc/time/strptime.c
@@ -292,11 +292,12 @@ strptime_l (const char *buf, const char *format, struct tm *timeptr,
ret = match_string (&buf, _ctloc (am_pm), locale);
if (ret < 0)
return NULL;
- if (timeptr->tm_hour == 0) {
- if (ret == 1)
- timeptr->tm_hour = 12;
- } else
- timeptr->tm_hour += 12;
+ if (timeptr->tm_hour > 12)
+ return NULL;
+ else if (timeptr->tm_hour == 12)
+ timeptr->tm_hour = ret * 12;
+ else
+ timeptr->tm_hour += ret * 12;
break;
case 'q' : /* quarter year - GNU extension */
ret = strtol_l (buf, &s, 10, locale);
--
2.34.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] strptime: fix am/pm converting to 24-hour system
2024-02-20 18:51 [PATCH] strptime: fix am/pm converting to 24-hour system Alexey Lapshin
@ 2024-02-21 14:53 ` Corinna Vinschen
0 siblings, 0 replies; 2+ messages in thread
From: Corinna Vinschen @ 2024-02-21 14:53 UTC (permalink / raw)
To: Alexey Lapshin; +Cc: newlib, Alexey Gerenkov, Ivan Grokhotkov
Hi Alexey,
On Feb 20 18:51, Alexey Lapshin wrote:
> Fix the issue of parsing 08:00AM, which currently gives a 20:00 representation.
>
> ---
> newlib/libc/time/strptime.c | 11 ++++++-----
> 1 file changed, 6 insertions(+), 5 deletions(-)
Pushed, thank you!
Corinna
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-02-21 14:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-20 18:51 [PATCH] strptime: fix am/pm converting to 24-hour system Alexey Lapshin
2024-02-21 14:53 ` Corinna Vinschen
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 read-only IMAP folder(s) and NNTP newsgroup(s).