date: better version of previous commit; + fix testsuite
to have it checked
This commit is contained in:
parent
e6520f0532
commit
e4ed64067e
@ -79,9 +79,11 @@ int date_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
|||||||
if (!(opt & (DATE_OPT_SET | DATE_OPT_DATE))) {
|
if (!(opt & (DATE_OPT_SET | DATE_OPT_DATE))) {
|
||||||
opt |= DATE_OPT_SET;
|
opt |= DATE_OPT_SET;
|
||||||
date_str = argv[0]; /* can be NULL */
|
date_str = argv[0]; /* can be NULL */
|
||||||
} else if (argv[0]) {
|
if (date_str)
|
||||||
bb_show_usage();
|
argv++;
|
||||||
}
|
}
|
||||||
|
if (*argv)
|
||||||
|
bb_show_usage();
|
||||||
|
|
||||||
/* Now we have parsed all the information except the date format
|
/* Now we have parsed all the information except the date format
|
||||||
which depends on whether the clock is being set or read */
|
which depends on whether the clock is being set or read */
|
||||||
|
@ -11,27 +11,29 @@ host_date=/bin/date
|
|||||||
# busybox 1.11.0.svn date reports:
|
# busybox 1.11.0.svn date reports:
|
||||||
# date: invalid date '1/2 3:4'
|
# date: invalid date '1/2 3:4'
|
||||||
|
|
||||||
hdt=`$host_date -d '1/2 3:4'`
|
# TODO: (1) compare with strings, not "host date"
|
||||||
dt=`busybox date -d 1.2-3:4`
|
# (2) implement d/m[/y] hh:mm[:ss] fmt in date applet
|
||||||
test x"$hdt" = x"$dt"
|
#hdt=`$host_date -d '1/2 3:4'`
|
||||||
|
#dt=`busybox date -d 1.2-3:4`
|
||||||
|
#test x"$hdt" = x"$dt"
|
||||||
|
|
||||||
hdt=`$host_date -d '1/2 3:4:5'`
|
#hdt=`$host_date -d '1/2 3:4:5'`
|
||||||
dt=`busybox date -d 1.2-3:4:5`
|
#dt=`busybox date -d 1.2-3:4:5`
|
||||||
test x"$hdt" = x"$dt"
|
#test x"$hdt" = x"$dt"
|
||||||
|
|
||||||
hdt=`$host_date -d '1/2/1999 3:4'`
|
#hdt=`$host_date -d '1/2/1999 3:4'`
|
||||||
dt=`busybox date -d 1999.1.2-3:4`
|
#dt=`busybox date -d 1999.1.2-3:4`
|
||||||
test x"$hdt" = x"$dt"
|
#test x"$hdt" = x"$dt"
|
||||||
|
|
||||||
hdt=`$host_date -d '1/2/1999 3:4:5'`
|
#hdt=`$host_date -d '1/2/1999 3:4:5'`
|
||||||
dt=`busybox date -d 1999.1.2-3:4:5`
|
#dt=`busybox date -d 1999.1.2-3:4:5`
|
||||||
test x"$hdt" = x"$dt"
|
#test x"$hdt" = x"$dt"
|
||||||
|
|
||||||
hdt=`$host_date -d '1999-1-2 3:4:5'`
|
hdt=`$host_date -d '1999-1-2 3:4:5'`
|
||||||
dt=`busybox date -d '1999-1-2 3:4:5'`
|
dt=`busybox date -d '1999-1-2 3:4:5'`
|
||||||
test x"$hdt" = x"$dt"
|
test x"$hdt" = x"$dt"
|
||||||
|
|
||||||
# Avoid using week day in this evaluation, as it's mostly different every year
|
# Avoiding using week day in this evaluation, as it's mostly different every year
|
||||||
# date (GNU coreutils) 6.10 reports:
|
# date (GNU coreutils) 6.10 reports:
|
||||||
# date: invalid date '01231133'
|
# date: invalid date '01231133'
|
||||||
dt=`busybox date -d 01231133 +%c`
|
dt=`busybox date -d 01231133 +%c`
|
||||||
@ -122,7 +124,6 @@ s=${s#0}
|
|||||||
|
|
||||||
test x"$res" = xOK
|
test x"$res" = xOK
|
||||||
|
|
||||||
if dt=`busybox date -d 012311332000.30 %+c`; then
|
# This should error out (by showing usage text). Testing for that
|
||||||
echo "Expected this to fail with: \"date: invalid date '%+c'\"" >&2
|
dt=`busybox date -d 012311332000.30 %+c 2>&1 | head -n 1`
|
||||||
exit 1
|
test x"${dt#BusyBox * multi-call binary}" = x
|
||||||
fi
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user