blob: e318944daebbc6fd7ed0112665777f869ff265df [file] [log] [blame]
Denis Vlasenko4809a9f2008-04-27 20:58:43 +00001dt=`busybox date -d 1:2 +%T`
2test x"$dt" = x"01:02:00"
3
4dt=`busybox date -d 1:2:3 +%T`
5test x"$dt" = x"01:02:03"
6
7host_date=/bin/date
8
9# date (GNU coreutils) 6.10 reports:
10# date: invalid date '1.2-3:4'
11# busybox 1.11.0.svn date reports:
12# date: invalid date '1/2 3:4'
13
Denis Vlasenkoe4ed6402008-04-28 00:25:22 +000014# TODO: (1) compare with strings, not "host date"
15# (2) implement d/m[/y] hh:mm[:ss] fmt in date applet
16#hdt=`$host_date -d '1/2 3:4'`
17#dt=`busybox date -d 1.2-3:4`
18#test x"$hdt" = x"$dt"
Denis Vlasenko4809a9f2008-04-27 20:58:43 +000019
Denis Vlasenkoe4ed6402008-04-28 00:25:22 +000020#hdt=`$host_date -d '1/2 3:4:5'`
21#dt=`busybox date -d 1.2-3:4:5`
22#test x"$hdt" = x"$dt"
Denis Vlasenko4809a9f2008-04-27 20:58:43 +000023
Denis Vlasenkoe4ed6402008-04-28 00:25:22 +000024#hdt=`$host_date -d '1/2/1999 3:4'`
25#dt=`busybox date -d 1999.1.2-3:4`
26#test x"$hdt" = x"$dt"
Denis Vlasenko4809a9f2008-04-27 20:58:43 +000027
Denis Vlasenkoe4ed6402008-04-28 00:25:22 +000028#hdt=`$host_date -d '1/2/1999 3:4:5'`
29#dt=`busybox date -d 1999.1.2-3:4:5`
30#test x"$hdt" = x"$dt"
Denis Vlasenko4809a9f2008-04-27 20:58:43 +000031
32hdt=`$host_date -d '1999-1-2 3:4:5'`
33dt=`busybox date -d '1999-1-2 3:4:5'`
34test x"$hdt" = x"$dt"
35
Denis Vlasenkoe4ed6402008-04-28 00:25:22 +000036# Avoiding using week day in this evaluation, as it's mostly different every year
Denis Vlasenko4809a9f2008-04-27 20:58:43 +000037# date (GNU coreutils) 6.10 reports:
38# date: invalid date '01231133'
39dt=`busybox date -d 01231133 +%c`
40dt=`echo "$dt" | cut -b5-19`
41test x"$dt" = x"Jan 23 11:33:00"
42
43# date (GNU coreutils) 6.10 reports:
44# date: invalid date '012311332000'
45dt=`busybox date -d 012311332000 +%c`
46test x"$dt" = x"Sun Jan 23 11:33:00 2000"
47
48# date (GNU coreutils) 6.10 reports:
49# date: invalid date '012311332000'
50dt=`busybox date -d 012311332000.30 +%c`
51test x"$dt" = x"Sun Jan 23 11:33:30 2000"
52
53lcbbd="LC_ALL=C busybox date"
54wd=$(eval $lcbbd +%a) # weekday name
55mn=$(eval $lcbbd +%b) # month name
56dm=$(eval $lcbbd +%e) # day of month, space padded
57h=$(eval $lcbbd +%H) # hour, zero padded
58m=$(eval $lcbbd +%M) # minute, zero padded
59s=$(eval $lcbbd +%S) # second, zero padded
60z=$(eval $lcbbd -u +%Z) # time zone abbreviation
61y=$(eval $lcbbd +%Y) # year
62
63res=OK
64case $wd in
65 Sun)
66 ;;
67 Mon)
68 ;;
69 Tue)
70 ;;
71 Wed)
72 ;;
73 Thu)
74 ;;
75 Fri)
76 ;;
77 Sat)
78 ;;
79 *)
80 res=BAD
81 ;;
82esac
83
84case $mn in
85 Jan)
86 ;;
87 Feb)
88 ;;
89 Mar)
90 ;;
91 Apr)
92 ;;
93 May)
94 ;;
95 Jun)
96 ;;
97 Jul)
98 ;;
99 Aug)
100 ;;
101 Sep)
102 ;;
103 Oct)
104 ;;
105 Nov)
106 ;;
107 Dec)
108 ;;
109 *)
110 res=BAD
111 ;;
112esac
113
114dm=${dm# *}
115[ $dm -ge 1 ] && [ $dm -le 31 ] || res=BAD
116h=${h#0}
117[ $h -ge 0 ] && [ $h -le 23 ] || res=BAD
118m=${m#0}
119[ $m -ge 0 ] && [ $m -le 59 ] || res=BAD
120s=${s#0}
121[ $s -ge 0 ] && [ $s -le 59 ] || res=BAD
122[ $z = UTC ] || res=BAD
123[ $y -ge 1970 ] || res=BAD
124
125test x"$res" = xOK
126
Denis Vlasenkoe4ed6402008-04-28 00:25:22 +0000127# This should error out (by showing usage text). Testing for that
128dt=`busybox date -d 012311332000.30 %+c 2>&1 | head -n 1`
129test x"${dt#BusyBox * multi-call binary}" = x