1 | unset LANG
|
---|
2 | unset LANGUAGE
|
---|
3 | unset LC_TIME
|
---|
4 | unset LC_ALL
|
---|
5 |
|
---|
6 | dt=`busybox date -d 1:2 +%T`
|
---|
7 | test x"$dt" = x"01:02:00"
|
---|
8 |
|
---|
9 | dt=`busybox date -d 1:2:3 +%T`
|
---|
10 | test x"$dt" = x"01:02:03"
|
---|
11 |
|
---|
12 | host_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 |
|
---|
37 | hdt=`$host_date -d '1999-1-2 3:4:5'`
|
---|
38 | dt=`busybox date -d '1999-1-2 3:4:5'`
|
---|
39 | test 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'
|
---|
44 | dt=`busybox date -d 01231133 +%c`
|
---|
45 | dt=`echo "$dt" | cut -b5-19`
|
---|
46 | test x"$dt" = x"Jan 23 11:33:00"
|
---|
47 |
|
---|
48 | # date (GNU coreutils) 6.10 reports:
|
---|
49 | # date: invalid date '012311332000'
|
---|
50 | dt=`busybox date -d 200001231133 +%c`
|
---|
51 | test x"$dt" = x"Sun Jan 23 11:33:00 2000"
|
---|
52 |
|
---|
53 | # date (GNU coreutils) 6.10 reports:
|
---|
54 | # date: invalid date '012311332000'
|
---|
55 | dt=`busybox date -d 200001231133.30 +%c`
|
---|
56 | test x"$dt" = x"Sun Jan 23 11:33:30 2000"
|
---|
57 |
|
---|
58 | lcbbd="LC_ALL=C busybox date"
|
---|
59 | wd=$(eval $lcbbd +%a) # weekday name
|
---|
60 | mn=$(eval $lcbbd +%b) # month name
|
---|
61 | dm=$(eval $lcbbd +%e) # day of month, space padded
|
---|
62 | h=$(eval $lcbbd +%H) # hour, zero padded
|
---|
63 | m=$(eval $lcbbd +%M) # minute, zero padded
|
---|
64 | s=$(eval $lcbbd +%S) # second, zero padded
|
---|
65 | z=$(eval $lcbbd -u +%Z) # time zone abbreviation
|
---|
66 | y=$(eval $lcbbd +%Y) # year
|
---|
67 |
|
---|
68 | res=OK
|
---|
69 | case $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 | ;;
|
---|
87 | esac
|
---|
88 |
|
---|
89 | case $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 | ;;
|
---|
117 | esac
|
---|
118 |
|
---|
119 | dm=${dm# *}
|
---|
120 | [ $dm -ge 1 ] && [ $dm -le 31 ] || res=BAD
|
---|
121 | h=${h#0}
|
---|
122 | [ $h -ge 0 ] && [ $h -le 23 ] || res=BAD
|
---|
123 | m=${m#0}
|
---|
124 | [ $m -ge 0 ] && [ $m -le 59 ] || res=BAD
|
---|
125 | s=${s#0}
|
---|
126 | [ $s -ge 0 ] && [ $s -le 59 ] || res=BAD
|
---|
127 | [ $z = UTC ] || res=BAD
|
---|
128 | [ $y -ge 1970 ] || res=BAD
|
---|
129 |
|
---|
130 | test x"$res" = xOK
|
---|
131 |
|
---|
132 | # This should error out (by showing usage text). Testing for that
|
---|
133 | dt=`busybox date -d 012311332000.30 %+c 2>&1 | head -n 1`
|
---|
134 | test x"${dt##BusyBox * multi-call binary*}" = x""
|
---|