diff options
author | Ron Yorston <rmy@pobox.com> | 2018-03-05 14:40:04 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2018-03-05 14:40:04 +0000 |
commit | 85165f87a8161946c683da5c4ecf58bbb6e46652 (patch) | |
tree | 9ba27122302b2e258b816d7d4e03a9fcdf60cbaa /win32 | |
parent | ce1d1546e17a5f613aad2bdf327a1abb77a32bdb (diff) | |
download | busybox-w32-85165f87a8161946c683da5c4ecf58bbb6e46652.tar.gz busybox-w32-85165f87a8161946c683da5c4ecf58bbb6e46652.tar.bz2 busybox-w32-85165f87a8161946c683da5c4ecf58bbb6e46652.zip |
win32: squeeze a few bytes out of strftime
Diffstat (limited to 'win32')
-rw-r--r-- | win32/mingw.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/win32/mingw.c b/win32/mingw.c index 4c449514a..f9967f1c4 100644 --- a/win32/mingw.c +++ b/win32/mingw.c | |||
@@ -972,9 +972,11 @@ size_t mingw_strftime(char *buf, size_t max, const char *format, const struct tm | |||
972 | int m; | 972 | int m; |
973 | 973 | ||
974 | /* | 974 | /* |
975 | * Emulate the '%e' and '%s' formats that Windows' strftime lacks. | 975 | * Emulate the some formats that Windows' strftime lacks. |
976 | * Happily, the string that replaces '%e' is two characters long. | 976 | * - '%e' day of the month with space padding |
977 | * '%s' is a bit more complicated. | 977 | * - '%s' number of seconds since the Unix epoch |
978 | * - '%z' timezone offset | ||
979 | * Also, permit the '-' modifier to omit padding. Windows uses '#'. | ||
978 | */ | 980 | */ |
979 | fmt = xstrdup(format); | 981 | fmt = xstrdup(format); |
980 | for ( t=fmt; *t; ++t ) { | 982 | for ( t=fmt; *t; ++t ) { |
@@ -1017,7 +1019,7 @@ size_t mingw_strftime(char *buf, size_t max, const char *format, const struct tm | |||
1017 | 1019 | ||
1018 | hr = offset / 3600; | 1020 | hr = offset / 3600; |
1019 | min = (offset % 3600) / 60; | 1021 | min = (offset % 3600) / 60; |
1020 | sprintf(buffer+1, "%02d%02d", hr, min); | 1022 | sprintf(buffer+1, "%04d", hr*100 + min); |
1021 | } | 1023 | } |
1022 | newfmt = xasprintf("%s%s%s", fmt, buffer, t+2); | 1024 | newfmt = xasprintf("%s%s%s", fmt, buffer, t+2); |
1023 | free(fmt); | 1025 | free(fmt); |