[PATCH 2/2] strptime.c(strptime_l): add %i, %q, %v

Brian Inglis <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <[email protected]>
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(-)
0002-strptime.c-strptime_l-add-i-q-v.patch (text/x-patch, 1.5 KB)
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)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.