From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id C0BBC3858D34; Wed, 21 Feb 2024 14:52:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C0BBC3858D34 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1708527176; bh=ArfB4WANdSl72JB8jNm7sP5F0MrPyg2fbRKIh3Cte7s=; h=From:To:Subject:Date:From; b=jPp0azEhDfaawVc064bvc+pqWy4cslKhfRoF7PbyP0JYE9eJXeaaCu2hu4zje0x4M z6/H28f1+VOZweArouCQlMPvanEEBmgnqtceqeCTNUG8wnDi9Fq2nKLZWnVYLnLWwb J4E7qAsOf29Z11JKrKk3T0ugql++qwJH5AakgXmE= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Corinna Vinschen To: newlib-cvs@sourceware.org Subject: [newlib-cygwin/main] strptime: fix am/pm converting to 24-hour system X-Act-Checkin: newlib-cygwin X-Git-Author: Alexey Lapshin X-Git-Refname: refs/heads/main X-Git-Oldrev: c90b20192dda446542a49578b9a74d8ee47f032c X-Git-Newrev: acf176104fc5410bfec0635ed2c5a21971b9c938 Message-Id: <20240221145256.C0BBC3858D34@sourceware.org> Date: Wed, 21 Feb 2024 14:52:56 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3Dacf176104fc= 5410bfec0635ed2c5a21971b9c938 commit acf176104fc5410bfec0635ed2c5a21971b9c938 Author: Alexey Lapshin AuthorDate: Tue Feb 20 18:51:04 2024 +0000 Commit: Corinna Vinschen CommitDate: Wed Feb 21 15:52:14 2024 +0100 strptime: fix am/pm converting to 24-hour system =20 Fix the issue of parsing 08:00AM, which currently gives a 20:00 represe= ntation. Diff: --- 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 6220ff73ad27..188218059a36 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, stru= ct tm *timeptr, ret =3D match_string (&buf, _ctloc (am_pm), locale); if (ret < 0) return NULL; - if (timeptr->tm_hour =3D=3D 0) { - if (ret =3D=3D 1) - timeptr->tm_hour =3D 12; - } else - timeptr->tm_hour +=3D 12; + if (timeptr->tm_hour > 12) + return NULL; + else if (timeptr->tm_hour =3D=3D 12) + timeptr->tm_hour =3D ret * 12; + else + timeptr->tm_hour +=3D ret * 12; break; case 'q' : /* quarter year - GNU extension */ ret =3D strtol_l (buf, &s, 10, locale);