From: Brian Inglis <Brian.Inglis@SystematicSW.ab.ca>
To: Newlib <newlib@Sourceware.org>
Subject: [PATCH 2/2] strptime.c(strptime_l): add %i, %q, %v
Date: Fri, 16 Sep 2022 23:00:04 -0600 [thread overview]
Message-ID: <20220917050005.5758-3-Brian.Inglis@SystematicSW.ab.ca> (raw)
In-Reply-To: <20220917050005.5758-1-Brian.Inglis@SystematicSW.ab.ca>
[-- Attachment #1: Type: text/plain, Size: 377 bytes --]
newlib/libc/time/strptime.c(strptime_l):
%i year in century [00..99] Synonym for "%y". Non-POSIX extension. [tm_year]
%q GNU quarter of the year (from `<<1>>' to `<<4>>') [tm_mon]
%v OSX/Ruby VMS/Oracle date "%d-%b-%Y". Non-POSIX extension. [tm_mday, tm_mon, tm_year]:
---
newlib/libc/time/strptime.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0002-strptime.c-strptime_l-add-i-q-v.patch --]
[-- Type: text/x-patch; name="0002-strptime.c-strptime_l-add-i-q-v.patch", Size: 1530 bytes --]
diff --git a/newlib/libc/time/strptime.c b/newlib/libc/time/strptime.c
index 12b2ef4695de..5e64af262516 100644
--- a/newlib/libc/time/strptime.c
+++ b/newlib/libc/time/strptime.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999 Kungliga Tekniska H?gskolan
+ * Copyright (c) 1999 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -298,6 +298,14 @@ strptime_l (const char *buf, const char *format, struct tm *timeptr,
} else
timeptr->tm_hour += 12;
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 */
s = strptime_l (buf, _ctloc (ampm_fmt), timeptr, locale);
if (s == NULL)
@@ -365,6 +373,13 @@ strptime_l (const char *buf, const char *format, struct tm *timeptr,
buf = s;
ymd |= SET_WDAY;
break;
+ case 'v' : /* %d-%b-%Y - OSX/Ruby extension VMS/Oracle date */
+ s = strptime_l (buf, "%d-%b-%Y", timeptr, locale);
+ if (s == NULL || s == buf)
+ return NULL;
+ buf = s;
+ ymd |= SET_YMD;
+ break;
case 'U' :
ret = strtol_l (buf, &s, 10, locale);
if (s == buf)
@@ -402,6 +417,7 @@ strptime_l (const char *buf, const char *format, struct tm *timeptr,
return NULL;
buf = s;
break;
+ case 'i' : /* Non-POSIX extension. */
case 'y' :
ret = strtol_l (buf, &s, 10, locale);
if (s == buf)
prev parent reply other threads:[~2022-09-17 5:00 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-17 5:00 [PATCH 0/2] strftime.c, strptime.c: add %i, %q, %v, tests; tweak %Z docs Brian Inglis
2022-09-17 5:00 ` [PATCH 1/2] strftime.c(__strftime): " Brian Inglis
[not found] ` <BN2P110MB15443B0E0009D450989B3ECF9A4D9@BN2P110MB1544.NAMP110.PROD.OUTLOOK.COM>
2022-09-19 15:51 ` Fw: " C Howland
2022-09-19 23:21 ` Brian Inglis
2022-10-18 14:03 ` Corinna Vinschen
2022-10-20 22:07 ` Brian Inglis
2022-10-21 12:12 ` Corinna Vinschen
2022-10-21 20:43 ` Brian Inglis
2022-09-17 5:00 ` Brian Inglis [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220917050005.5758-3-Brian.Inglis@SystematicSW.ab.ca \
--to=brian.inglis@systematicsw.ab.ca \
--cc=newlib@Sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).