aboutsummaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2000-11-17 18:51:45 +0000
committerEric Andersen <andersen@codepoet.org>2000-11-17 18:51:45 +0000
commita683ee81d918f338a8335d4f03057106b701afec (patch)
tree0d6fa23ebe6b2c0f3ffc26b2e848e3b480804573 /coreutils
parente5aef92e22172d36152bae6e15d5c0419c758121 (diff)
downloadbusybox-a683ee81d918f338a8335d4f03057106b701afec.tar.gz
"I will always compile before I commit."
"I will always compile before I commit." "I will always compile before I commit." -Erik
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/date.c51
1 files changed, 30 insertions, 21 deletions
diff --git a/coreutils/date.c b/coreutils/date.c
index 2e99aea19..a8f0d7ced 100644
--- a/coreutils/date.c
+++ b/coreutils/date.c
@@ -160,26 +160,27 @@ int date_main(int argc, char **argv)
/* Interpret command line args */
while ((c = getopt(argc, argv, "Rs:ud:")) != EOF) {
switch (c) {
- case 'R':
- rfc822 = 1;
- break;
- case 's':
- set_time = 1;
- if ((date_str != NULL) || ((date_str = optarg) == NULL))
+ case 'R':
+ rfc822 = 1;
+ break;
+ case 's':
+ set_time = 1;
+ if ((date_str != NULL) || ((date_str = optarg) == NULL)) {
+ usage(date_usage);
+ }
+ break;
+ case 'u':
+ utc = 1;
+ if (putenv("TZ=UTC0") != 0)
+ fatalError(memory_exhausted);
+ break;
+ case 'd':
+ use_arg = 1;
+ if ((date_str != NULL) || ((date_str = optarg) == NULL))
+ usage(date_usage);
+ break;
+ default:
usage(date_usage);
- break;
- case 'u':
- utc = 1;
- if (putenv("TZ=UTC0") != 0)
- fatalError(memory_exhausted);
- break;
- case 'd':
- use_arg = 1;
- if ((date_str != NULL) || ((date_str = optarg) == NULL))
- usage(date_usage);
- break;
- default:
- usage(date_usage);
}
}
@@ -188,9 +189,13 @@ int date_main(int argc, char **argv)
else if (date_str == NULL) {
set_time = 1;
date_str = argv[optind];
- } else {
+ }
+#if 0
+ else {
+ errorMsg("date_str='%s' date_fmt='%s'\n", date_str, date_fmt);
usage(date_usage);
}
+#endif
/* Now we have parsed all the information except the date format
which depends on whether the clock is being set or read */
@@ -217,11 +222,15 @@ int date_main(int argc, char **argv)
tm = mktime(&tm_time);
if (tm < 0)
fatalError(invalid_date, date_str);
+ if ( utc ) {
+ if (putenv("TZ=UTC0") != 0)
+ fatalError(memory_exhausted);
+ }
/* if setting time, set it */
if (set_time) {
if (stime(&tm) < 0) {
- fatalError("can't set date.\n");
+ perrorMsg("cannot set date");
}
}
}