46 lines
1.5 KiB
Diff
46 lines
1.5 KiB
Diff
From 93df169bb52d83027d77f17c30212a1b109cfc9d Mon Sep 17 00:00:00 2001
|
|
From: Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
|
|
Date: Sat, 19 Apr 2008 17:42:20 +0200
|
|
Subject: [PATCH 13/18] Fixes/enhancements in str?time() functions
|
|
|
|
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.
|
|
---
|
|
libugly/strftime.c | 1 +
|
|
libugly/strptime.c | 5 +++--
|
|
2 files changed, 4 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/libugly/strftime.c b/libugly/strftime.c
|
|
index 56ae082..cf16f37 100644
|
|
--- a/libugly/strftime.c
|
|
+++ b/libugly/strftime.c
|
|
@@ -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 --git a/libugly/strptime.c b/libugly/strptime.c
|
|
index 9d7f530..d19f309 100644
|
|
--- a/libugly/strptime.c
|
|
+++ b/libugly/strptime.c
|
|
@@ -119,10 +119,11 @@ char* strptime(const char* s,const char* format, struct tm* tm) {
|
|
++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);
|
|
--
|
|
1.6.2.5
|
|
|