diff options
| author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-04-28 00:25:22 +0000 |
|---|---|---|
| committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-04-28 00:25:22 +0000 |
| commit | e4ed64067e7de0607cfb23b95a542e29a84bf1fa (patch) | |
| tree | 43baa202b5a72a3fadc3cd9cd5e2a814ba9f389b | |
| parent | e6520f05328c38333284df5f42b9c2bfb7c4fec9 (diff) | |
| download | busybox-w32-e4ed64067e7de0607cfb23b95a542e29a84bf1fa.tar.gz busybox-w32-e4ed64067e7de0607cfb23b95a542e29a84bf1fa.tar.bz2 busybox-w32-e4ed64067e7de0607cfb23b95a542e29a84bf1fa.zip | |
date: better version of previous commit; + fix testsuite
to have it checked
| -rw-r--r-- | coreutils/date.c | 6 | ||||
| -rw-r--r-- | testsuite/date/date-works-1 | 35 |
2 files changed, 22 insertions, 19 deletions
diff --git a/coreutils/date.c b/coreutils/date.c index 2c61aa646..5b0f60f1a 100644 --- a/coreutils/date.c +++ b/coreutils/date.c | |||
| @@ -79,9 +79,11 @@ int date_main(int argc ATTRIBUTE_UNUSED, char **argv) | |||
| 79 | if (!(opt & (DATE_OPT_SET | DATE_OPT_DATE))) { | 79 | if (!(opt & (DATE_OPT_SET | DATE_OPT_DATE))) { |
| 80 | opt |= DATE_OPT_SET; | 80 | opt |= DATE_OPT_SET; |
| 81 | date_str = argv[0]; /* can be NULL */ | 81 | date_str = argv[0]; /* can be NULL */ |
| 82 | } else if (argv[0]) { | 82 | if (date_str) |
| 83 | bb_show_usage(); | 83 | argv++; |
| 84 | } | 84 | } |
| 85 | if (*argv) | ||
| 86 | bb_show_usage(); | ||
| 85 | 87 | ||
| 86 | /* Now we have parsed all the information except the date format | 88 | /* Now we have parsed all the information except the date format |
| 87 | which depends on whether the clock is being set or read */ | 89 | which depends on whether the clock is being set or read */ |
diff --git a/testsuite/date/date-works-1 b/testsuite/date/date-works-1 index 11d8b2b7c..e318944da 100644 --- a/testsuite/date/date-works-1 +++ b/testsuite/date/date-works-1 | |||
| @@ -11,27 +11,29 @@ host_date=/bin/date | |||
| 11 | # busybox 1.11.0.svn date reports: | 11 | # busybox 1.11.0.svn date reports: |
| 12 | # date: invalid date '1/2 3:4' | 12 | # date: invalid date '1/2 3:4' |
| 13 | 13 | ||
| 14 | hdt=`$host_date -d '1/2 3:4'` | 14 | # TODO: (1) compare with strings, not "host date" |
| 15 | dt=`busybox date -d 1.2-3:4` | 15 | # (2) implement d/m[/y] hh:mm[:ss] fmt in date applet |
| 16 | test x"$hdt" = x"$dt" | 16 | #hdt=`$host_date -d '1/2 3:4'` |
| 17 | #dt=`busybox date -d 1.2-3:4` | ||
| 18 | #test x"$hdt" = x"$dt" | ||
| 17 | 19 | ||
| 18 | hdt=`$host_date -d '1/2 3:4:5'` | 20 | #hdt=`$host_date -d '1/2 3:4:5'` |
| 19 | dt=`busybox date -d 1.2-3:4:5` | 21 | #dt=`busybox date -d 1.2-3:4:5` |
| 20 | test x"$hdt" = x"$dt" | 22 | #test x"$hdt" = x"$dt" |
| 21 | 23 | ||
| 22 | hdt=`$host_date -d '1/2/1999 3:4'` | 24 | #hdt=`$host_date -d '1/2/1999 3:4'` |
| 23 | dt=`busybox date -d 1999.1.2-3:4` | 25 | #dt=`busybox date -d 1999.1.2-3:4` |
| 24 | test x"$hdt" = x"$dt" | 26 | #test x"$hdt" = x"$dt" |
| 25 | 27 | ||
| 26 | hdt=`$host_date -d '1/2/1999 3:4:5'` | 28 | #hdt=`$host_date -d '1/2/1999 3:4:5'` |
| 27 | dt=`busybox date -d 1999.1.2-3:4:5` | 29 | #dt=`busybox date -d 1999.1.2-3:4:5` |
| 28 | test x"$hdt" = x"$dt" | 30 | #test x"$hdt" = x"$dt" |
| 29 | 31 | ||
| 30 | hdt=`$host_date -d '1999-1-2 3:4:5'` | 32 | hdt=`$host_date -d '1999-1-2 3:4:5'` |
| 31 | dt=`busybox date -d '1999-1-2 3:4:5'` | 33 | dt=`busybox date -d '1999-1-2 3:4:5'` |
| 32 | test x"$hdt" = x"$dt" | 34 | test x"$hdt" = x"$dt" |
| 33 | 35 | ||
| 34 | # Avoid using week day in this evaluation, as it's mostly different every year | 36 | # Avoiding using week day in this evaluation, as it's mostly different every year |
| 35 | # date (GNU coreutils) 6.10 reports: | 37 | # date (GNU coreutils) 6.10 reports: |
| 36 | # date: invalid date '01231133' | 38 | # date: invalid date '01231133' |
| 37 | dt=`busybox date -d 01231133 +%c` | 39 | dt=`busybox date -d 01231133 +%c` |
| @@ -122,7 +124,6 @@ s=${s#0} | |||
| 122 | 124 | ||
| 123 | test x"$res" = xOK | 125 | test x"$res" = xOK |
| 124 | 126 | ||
| 125 | if dt=`busybox date -d 012311332000.30 %+c`; then | 127 | # This should error out (by showing usage text). Testing for that |
| 126 | echo "Expected this to fail with: \"date: invalid date '%+c'\"" >&2 | 128 | dt=`busybox date -d 012311332000.30 %+c 2>&1 | head -n 1` |
| 127 | exit 1 | 129 | test x"${dt#BusyBox * multi-call binary}" = x |
| 128 | fi | ||
