diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2010-09-14 19:48:30 +1000 |
---|---|---|
committer | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2010-09-14 19:51:47 +1000 |
commit | a2486b548b1636729edc34172a08fd18864e7fa8 (patch) | |
tree | e020ccd5c0accefead56124e169571e92a0bb1cf | |
parent | 42b6a4c89ad8d4f625a3b63b7556929e3a660e90 (diff) | |
download | busybox-w32-a2486b548b1636729edc34172a08fd18864e7fa8.tar.gz busybox-w32-a2486b548b1636729edc34172a08fd18864e7fa8.tar.bz2 busybox-w32-a2486b548b1636729edc34172a08fd18864e7fa8.zip |
win32: enable date
Setting time does not work. %e does not work because strftime does
not support that. Output may be different from POSIX because "it is
Windows" syndrome.
-rw-r--r-- | coreutils/date.c | 13 | ||||
-rw-r--r-- | include/mingw.h | 4 | ||||
-rw-r--r-- | scripts/defconfig.mingw32 | 6 |
3 files changed, 20 insertions, 3 deletions
diff --git a/coreutils/date.c b/coreutils/date.c index c9dfedf81..c0faf04af 100644 --- a/coreutils/date.c +++ b/coreutils/date.c | |||
@@ -242,9 +242,14 @@ int date_main(int argc UNUSED_PARAM, char **argv) | |||
242 | maybe_set_utc(opt); | 242 | maybe_set_utc(opt); |
243 | 243 | ||
244 | /* if setting time, set it */ | 244 | /* if setting time, set it */ |
245 | #if ENABLE_PLATFORM_MINGW32 | ||
246 | if (opt & OPT_SET) | ||
247 | bb_error_msg_and_die("Setting date is not supported"); | ||
248 | #else | ||
245 | if ((opt & OPT_SET) && stime(&ts.tv_sec) < 0) { | 249 | if ((opt & OPT_SET) && stime(&ts.tv_sec) < 0) { |
246 | bb_perror_msg("can't set date"); | 250 | bb_perror_msg("can't set date"); |
247 | } | 251 | } |
252 | #endif | ||
248 | } | 253 | } |
249 | 254 | ||
250 | /* Display output */ | 255 | /* Display output */ |
@@ -272,7 +277,11 @@ int date_main(int argc UNUSED_PARAM, char **argv) | |||
272 | i = sizeof("%a, %d %b %Y %H:%M:%S ")-1; | 277 | i = sizeof("%a, %d %b %Y %H:%M:%S ")-1; |
273 | goto format_utc; | 278 | goto format_utc; |
274 | } else { /* default case */ | 279 | } else { /* default case */ |
280 | #if ENABLE_PLATFORM_MINGW32 | ||
281 | fmt_dt2str = (char*)"%a %b %d %H:%M:%S %Z %Y"; | ||
282 | #else | ||
275 | fmt_dt2str = (char*)"%a %b %e %H:%M:%S %Z %Y"; | 283 | fmt_dt2str = (char*)"%a %b %e %H:%M:%S %Z %Y"; |
284 | #endif | ||
276 | } | 285 | } |
277 | } | 286 | } |
278 | #if ENABLE_FEATURE_DATE_NANO | 287 | #if ENABLE_FEATURE_DATE_NANO |
@@ -325,6 +334,10 @@ int date_main(int argc UNUSED_PARAM, char **argv) | |||
325 | if (strncmp(fmt_dt2str, "%f", 2) == 0) { | 334 | if (strncmp(fmt_dt2str, "%f", 2) == 0) { |
326 | fmt_dt2str = (char*)"%Y.%m.%d-%H:%M:%S"; | 335 | fmt_dt2str = (char*)"%Y.%m.%d-%H:%M:%S"; |
327 | } | 336 | } |
337 | #if ENABLE_PLATFORM_MINGW32 | ||
338 | if (strstr(fmt_dt2str, "%e")) | ||
339 | bb_error_msg_and_die("%e is not supported by Windows strftime"); | ||
340 | #endif | ||
328 | /* Generate output string */ | 341 | /* Generate output string */ |
329 | strftime(date_buf, sizeof(date_buf), fmt_dt2str, &tm_time); | 342 | strftime(date_buf, sizeof(date_buf), fmt_dt2str, &tm_time); |
330 | } | 343 | } |
diff --git a/include/mingw.h b/include/mingw.h index 53a0a0d67..e7c385ec6 100644 --- a/include/mingw.h +++ b/include/mingw.h | |||
@@ -235,6 +235,10 @@ int mingw_fstat(int fd, struct stat *buf); | |||
235 | /* | 235 | /* |
236 | * sys/time.h | 236 | * sys/time.h |
237 | */ | 237 | */ |
238 | struct timespec { | ||
239 | time_t tv_sec; | ||
240 | long int tv_nsec; | ||
241 | }; | ||
238 | struct itimerval { | 242 | struct itimerval { |
239 | struct timeval it_value, it_interval; | 243 | struct timeval it_value, it_interval; |
240 | }; | 244 | }; |
diff --git a/scripts/defconfig.mingw32 b/scripts/defconfig.mingw32 index 943c3f4ab..66422f9b0 100644 --- a/scripts/defconfig.mingw32 +++ b/scripts/defconfig.mingw32 | |||
@@ -169,10 +169,10 @@ CONFIG_UNZIP=y | |||
169 | # | 169 | # |
170 | CONFIG_BASENAME=y | 170 | CONFIG_BASENAME=y |
171 | CONFIG_CAT=y | 171 | CONFIG_CAT=y |
172 | # CONFIG_DATE is not set | 172 | CONFIG_DATE=y |
173 | # CONFIG_FEATURE_DATE_ISOFMT is not set | 173 | CONFIG_FEATURE_DATE_ISOFMT=y |
174 | # CONFIG_FEATURE_DATE_NANO is not set | 174 | # CONFIG_FEATURE_DATE_NANO is not set |
175 | # CONFIG_FEATURE_DATE_COMPAT is not set | 175 | CONFIG_FEATURE_DATE_COMPAT=y |
176 | CONFIG_TEST=y | 176 | CONFIG_TEST=y |
177 | CONFIG_FEATURE_TEST_64=y | 177 | CONFIG_FEATURE_TEST_64=y |
178 | CONFIG_TR=y | 178 | CONFIG_TR=y |