This patch changes the used format for %x and %X specifiers in strptime(3)

to match these specified by SUSv2. It adds support for '%F' in
    strftime(3) too.
This commit is contained in:
ensc 2008-06-21 13:49:04 +00:00
commit bce265ae63

View file

@ -0,0 +1,28 @@
diff -up dietlibc-0.31.20080409/libugly/strftime.c.lcctime dietlibc-0.31.20080409/libugly/strftime.c
--- dietlibc-0.31.20080409/libugly/strftime.c.lcctime 2006-08-15 18:07:15.000000000 +0200
+++ dietlibc-0.31.20080409/libugly/strftime.c 2008-04-13 13:20:41.000000000 +0200
@@ -55,6 +55,7 @@ again:
case 'x': src = "%b %a %d"; goto _strf;
case 'X': src = "%k:%M:%S"; goto _strf;
case 'D': src = "%m/%d/%y"; goto _strf;
+ case 'F': src = "%Y-%m-%d"; goto _strf;
case 'T': src = "%H:%M:%S";
_strf: p += strftime (p, (size_t)(dst+max-p), src, tm); break;
case 'a': src = sweekdays [tm->tm_wday]; goto _str;
diff -up dietlibc-0.31.20080409/libugly/strptime.c.lcctime dietlibc-0.31.20080409/libugly/strptime.c
--- dietlibc-0.31.20080409/libugly/strptime.c.lcctime 2007-08-03 22:58:33.000000000 +0200
+++ dietlibc-0.31.20080409/libugly/strptime.c 2008-04-13 13:13:12.000000000 +0200
@@ -119,10 +119,11 @@ char* strptime(const char* s,const char*
++s;
break;
case 'x':
- s=strptime(s,"%b %a %d",tm);
+ /* see SUSv2, Ch.7 "LC_TIME Category in the POSIX Locale" */
+ s=strptime(s,"%m/%d/%y",tm);
break;
case 'X':
- s=strptime(s,"%k:%M:%S",tm);
+ s=strptime(s,"%H:%M:%S",tm);
break;
case 'y':
i=getint(&s,2);