From a2486b548b1636729edc34172a08fd18864e7fa8 Mon Sep 17 00:00:00 2001 From: Nguyễn Thái Ngọc Duy Date: Tue, 14 Sep 2010 19:48:30 +1000 Subject: 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. --- coreutils/date.c | 13 +++++++++++++ include/mingw.h | 4 ++++ 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) maybe_set_utc(opt); /* if setting time, set it */ +#if ENABLE_PLATFORM_MINGW32 + if (opt & OPT_SET) + bb_error_msg_and_die("Setting date is not supported"); +#else if ((opt & OPT_SET) && stime(&ts.tv_sec) < 0) { bb_perror_msg("can't set date"); } +#endif } /* Display output */ @@ -272,7 +277,11 @@ int date_main(int argc UNUSED_PARAM, char **argv) i = sizeof("%a, %d %b %Y %H:%M:%S ")-1; goto format_utc; } else { /* default case */ +#if ENABLE_PLATFORM_MINGW32 + fmt_dt2str = (char*)"%a %b %d %H:%M:%S %Z %Y"; +#else fmt_dt2str = (char*)"%a %b %e %H:%M:%S %Z %Y"; +#endif } } #if ENABLE_FEATURE_DATE_NANO @@ -325,6 +334,10 @@ int date_main(int argc UNUSED_PARAM, char **argv) if (strncmp(fmt_dt2str, "%f", 2) == 0) { fmt_dt2str = (char*)"%Y.%m.%d-%H:%M:%S"; } +#if ENABLE_PLATFORM_MINGW32 + if (strstr(fmt_dt2str, "%e")) + bb_error_msg_and_die("%e is not supported by Windows strftime"); +#endif /* Generate output string */ strftime(date_buf, sizeof(date_buf), fmt_dt2str, &tm_time); } 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); /* * sys/time.h */ +struct timespec { + time_t tv_sec; + long int tv_nsec; +}; struct itimerval { struct timeval it_value, it_interval; }; 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 # CONFIG_BASENAME=y CONFIG_CAT=y -# CONFIG_DATE is not set -# CONFIG_FEATURE_DATE_ISOFMT is not set +CONFIG_DATE=y +CONFIG_FEATURE_DATE_ISOFMT=y # CONFIG_FEATURE_DATE_NANO is not set -# CONFIG_FEATURE_DATE_COMPAT is not set +CONFIG_FEATURE_DATE_COMPAT=y CONFIG_TEST=y CONFIG_FEATURE_TEST_64=y CONFIG_TR=y -- cgit v1.2.3-55-g6feb