strptime.c(strptime_l): add %q GNU quarter

This commit is contained in:
Brian Inglis 2022-10-21 23:15:18 -06:00 committed by Corinna Vinschen
parent 7589034cc3
commit d6a26e542d
1 changed files with 9 additions and 1 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999 Kungliga Tekniska Högskolan * Copyright (c) 1999 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden). * (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved. * All rights reserved.
* *
@ -298,6 +298,14 @@ strptime_l (const char *buf, const char *format, struct tm *timeptr,
} else } else
timeptr->tm_hour += 12; timeptr->tm_hour += 12;
break; break;
case 'q' : /* quarter year - GNU extension */
ret = strtol_l (buf, &s, 10, locale);
if (s == buf)
return NULL;
timeptr->tm_mon = (ret - 1)*3;
buf = s;
ymd |= SET_MON;
break;
case 'r' : /* %I:%M:%S %p */ case 'r' : /* %I:%M:%S %p */
s = strptime_l (buf, _ctloc (ampm_fmt), timeptr, locale); s = strptime_l (buf, _ctloc (ampm_fmt), timeptr, locale);
if (s == NULL) if (s == NULL)