diff options
| author | Ron Yorston <rmy@pobox.com> | 2014-12-02 16:32:56 +0000 |
|---|---|---|
| committer | Ron Yorston <rmy@pobox.com> | 2014-12-02 16:32:56 +0000 |
| commit | a85d49580e2c1251d7ea9eebad672f802d82ec40 (patch) | |
| tree | ec103aca9e39eb690a92a2ad5e5f03c97af25ae6 | |
| parent | 7ef60bda00dc4b2fbccf67a40885569ab45eb7aa (diff) | |
| download | busybox-w32-a85d49580e2c1251d7ea9eebad672f802d82ec40.tar.gz busybox-w32-a85d49580e2c1251d7ea9eebad672f802d82ec40.tar.bz2 busybox-w32-a85d49580e2c1251d7ea9eebad672f802d82ec40.zip | |
date: add support for %s format
| -rw-r--r-- | win32/mingw.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/win32/mingw.c b/win32/mingw.c index eeafd7d75..8a124147a 100644 --- a/win32/mingw.c +++ b/win32/mingw.c | |||
| @@ -837,11 +837,14 @@ size_t mingw_strftime(char *buf, size_t max, const char *format, const struct tm | |||
| 837 | size_t ret; | 837 | size_t ret; |
| 838 | char day[3]; | 838 | char day[3]; |
| 839 | char *t; | 839 | char *t; |
| 840 | char *fmt; | 840 | char *fmt, *newfmt; |
| 841 | struct tm tm2; | ||
| 842 | int m; | ||
| 841 | 843 | ||
| 842 | /* | 844 | /* |
| 843 | * Emulate the '%e' format that Windows' strftime lacks. Happily, the | 845 | * Emulate the '%e' and '%s' formats that Windows' strftime lacks. |
| 844 | * string that replaces '%e' is always two characters long. | 846 | * Happily, the string that replaces '%e' is two characters long. |
| 847 | * '%s' is a bit more complicated. | ||
| 845 | */ | 848 | */ |
| 846 | fmt = xstrdup(format); | 849 | fmt = xstrdup(format); |
| 847 | for ( t=fmt; *t; ++t ) { | 850 | for ( t=fmt; *t; ++t ) { |
| @@ -855,6 +858,15 @@ size_t mingw_strftime(char *buf, size_t max, const char *format, const struct tm | |||
| 855 | } | 858 | } |
| 856 | memcpy(t++, day, 2); | 859 | memcpy(t++, day, 2); |
| 857 | } | 860 | } |
| 861 | else if ( t[1] == 's' ) { | ||
| 862 | *t = '\0'; | ||
| 863 | m = t - fmt; | ||
| 864 | tm2 = *tm; | ||
| 865 | newfmt = xasprintf("%s%d%s", fmt, (int)mktime(&tm2), t+2); | ||
| 866 | free(fmt); | ||
| 867 | t = newfmt + m + 1; | ||
| 868 | fmt = newfmt; | ||
| 869 | } | ||
| 858 | else if ( t[1] != '\0' ) { | 870 | else if ( t[1] != '\0' ) { |
| 859 | ++t; | 871 | ++t; |
| 860 | } | 872 | } |
