source: branches/3.2/mindi-busybox/testsuite/date/date-works-1 @ 3232

Last change on this file since 3232 was 2725, checked in by Bruno Cornec, 9 years ago
  • Update mindi-busybox to 1.18.3 to avoid problems with the tar command which is now failing on recent versions with busybox 1.7.3
File size: 2.5 KB
Line 
1unset LANG
2unset LANGUAGE
3unset LC_TIME
4unset LC_ALL
5
6dt=`busybox date -d 1:2 +%T`
7test x"$dt" = x"01:02:00"
8
9dt=`busybox date -d 1:2:3 +%T`
10test x"$dt" = x"01:02:03"
11
12host_date=/bin/date
13
14# date (GNU coreutils) 6.10 reports:
15#   date: invalid date '1.2-3:4'
16# busybox 1.11.0.svn date reports:
17#   date: invalid date '1/2 3:4'
18
19# TODO: (1) compare with strings, not "host date"
20# (2) implement d/m[/y] hh:mm[:ss] fmt in date applet
21#hdt=`$host_date -d '1/2 3:4'`
22#dt=`busybox date -d 1.2-3:4`
23#test x"$hdt" = x"$dt"
24
25#hdt=`$host_date -d '1/2 3:4:5'`
26#dt=`busybox date -d 1.2-3:4:5`
27#test x"$hdt" = x"$dt"
28
29#hdt=`$host_date -d '1/2/1999 3:4'`
30#dt=`busybox date -d 1999.1.2-3:4`
31#test x"$hdt" = x"$dt"
32
33#hdt=`$host_date -d '1/2/1999 3:4:5'`
34#dt=`busybox date -d 1999.1.2-3:4:5`
35#test x"$hdt" = x"$dt"
36
37hdt=`$host_date -d '1999-1-2 3:4:5'`
38dt=`busybox date -d '1999-1-2 3:4:5'`
39test x"$hdt" = x"$dt"
40
41# Avoiding using week day in this evaluation, as it's mostly different every year
42# date (GNU coreutils) 6.10 reports:
43#   date: invalid date '01231133'
44dt=`busybox date -d 01231133 +%c`
45dt=`echo "$dt" | cut -b5-19`
46test x"$dt" = x"Jan 23 11:33:00"
47
48# date (GNU coreutils) 6.10 reports:
49#   date: invalid date '012311332000'
50dt=`busybox date -d 200001231133 +%c`
51test x"$dt" = x"Sun Jan 23 11:33:00 2000"
52
53# date (GNU coreutils) 6.10 reports:
54#   date: invalid date '012311332000'
55dt=`busybox date -d 200001231133.30 +%c`
56test x"$dt" = x"Sun Jan 23 11:33:30 2000"
57
58lcbbd="LC_ALL=C busybox date"
59wd=$(eval $lcbbd +%a)       # weekday name
60mn=$(eval $lcbbd +%b)       # month name
61dm=$(eval $lcbbd +%e)       # day of month, space padded
62h=$(eval $lcbbd +%H)        # hour, zero padded
63m=$(eval $lcbbd +%M)        # minute, zero padded
64s=$(eval $lcbbd +%S)        # second, zero padded
65z=$(eval $lcbbd -u +%Z)     # time zone abbreviation
66y=$(eval $lcbbd +%Y)        # year
67
68res=OK
69case $wd in
70    Sun)
71        ;;
72    Mon)
73        ;;
74    Tue)
75        ;;
76    Wed)
77        ;;
78    Thu)
79        ;;
80    Fri)
81        ;;
82    Sat)
83        ;;
84    *)
85        res=BAD
86        ;;
87esac
88
89case $mn in
90    Jan)
91        ;;
92    Feb)
93        ;;
94    Mar)
95        ;;
96    Apr)
97        ;;
98    May)
99        ;;
100    Jun)
101        ;;
102    Jul)
103        ;;
104    Aug)
105        ;;
106    Sep)
107        ;;
108    Oct)
109        ;;
110    Nov)
111        ;;
112    Dec)
113        ;;
114    *)
115        res=BAD
116        ;;
117esac
118
119dm=${dm# *}
120[ $dm -ge 1 ] && [ $dm -le 31 ] || res=BAD
121h=${h#0}
122[ $h -ge 0 ] && [ $h -le 23 ] || res=BAD
123m=${m#0}
124[ $m -ge 0 ] && [ $m -le 59 ] || res=BAD
125s=${s#0}
126[ $s -ge 0 ] && [ $s -le 59 ] || res=BAD
127[ $z = UTC ] || res=BAD
128[ $y -ge 1970 ] || res=BAD
129
130test x"$res" = xOK
131
132# This should error out (by showing usage text). Testing for that
133dt=`busybox date -d 012311332000.30 %+c 2>&1 | head -n 1`
134test x"${dt##BusyBox * multi-call binary*}" = x""
Note: See TracBrowser for help on using the repository browser.