aboutsummaryrefslogtreecommitdiff
path: root/testsuite/date/date-works-1
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/date/date-works-1')
-rw-r--r--testsuite/date/date-works-1128
1 files changed, 128 insertions, 0 deletions
diff --git a/testsuite/date/date-works-1 b/testsuite/date/date-works-1
new file mode 100644
index 000000000..11d8b2b7c
--- /dev/null
+++ b/testsuite/date/date-works-1
@@ -0,0 +1,128 @@
1dt=`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
14hdt=`$host_date -d '1/2 3:4'`
15dt=`busybox date -d 1.2-3:4`
16test x"$hdt" = x"$dt"
17
18hdt=`$host_date -d '1/2 3:4:5'`
19dt=`busybox date -d 1.2-3:4:5`
20test x"$hdt" = x"$dt"
21
22hdt=`$host_date -d '1/2/1999 3:4'`
23dt=`busybox date -d 1999.1.2-3:4`
24test x"$hdt" = x"$dt"
25
26hdt=`$host_date -d '1/2/1999 3:4:5'`
27dt=`busybox date -d 1999.1.2-3:4:5`
28test x"$hdt" = x"$dt"
29
30hdt=`$host_date -d '1999-1-2 3:4:5'`
31dt=`busybox date -d '1999-1-2 3:4:5'`
32test x"$hdt" = x"$dt"
33
34# Avoid using week day in this evaluation, as it's mostly different every year
35# date (GNU coreutils) 6.10 reports:
36# date: invalid date '01231133'
37dt=`busybox date -d 01231133 +%c`
38dt=`echo "$dt" | cut -b5-19`
39test x"$dt" = x"Jan 23 11:33:00"
40
41# date (GNU coreutils) 6.10 reports:
42# date: invalid date '012311332000'
43dt=`busybox date -d 012311332000 +%c`
44test x"$dt" = x"Sun Jan 23 11:33:00 2000"
45
46# date (GNU coreutils) 6.10 reports:
47# date: invalid date '012311332000'
48dt=`busybox date -d 012311332000.30 +%c`
49test x"$dt" = x"Sun Jan 23 11:33:30 2000"
50
51lcbbd="LC_ALL=C busybox date"
52wd=$(eval $lcbbd +%a) # weekday name
53mn=$(eval $lcbbd +%b) # month name
54dm=$(eval $lcbbd +%e) # day of month, space padded
55h=$(eval $lcbbd +%H) # hour, zero padded
56m=$(eval $lcbbd +%M) # minute, zero padded
57s=$(eval $lcbbd +%S) # second, zero padded
58z=$(eval $lcbbd -u +%Z) # time zone abbreviation
59y=$(eval $lcbbd +%Y) # year
60
61res=OK
62case $wd in
63 Sun)
64 ;;
65 Mon)
66 ;;
67 Tue)
68 ;;
69 Wed)
70 ;;
71 Thu)
72 ;;
73 Fri)
74 ;;
75 Sat)
76 ;;
77 *)
78 res=BAD
79 ;;
80esac
81
82case $mn in
83 Jan)
84 ;;
85 Feb)
86 ;;
87 Mar)
88 ;;
89 Apr)
90 ;;
91 May)
92 ;;
93 Jun)
94 ;;
95 Jul)
96 ;;
97 Aug)
98 ;;
99 Sep)
100 ;;
101 Oct)
102 ;;
103 Nov)
104 ;;
105 Dec)
106 ;;
107 *)
108 res=BAD
109 ;;
110esac
111
112dm=${dm# *}
113[ $dm -ge 1 ] && [ $dm -le 31 ] || res=BAD
114h=${h#0}
115[ $h -ge 0 ] && [ $h -le 23 ] || res=BAD
116m=${m#0}
117[ $m -ge 0 ] && [ $m -le 59 ] || res=BAD
118s=${s#0}
119[ $s -ge 0 ] && [ $s -le 59 ] || res=BAD
120[ $z = UTC ] || res=BAD
121[ $y -ge 1970 ] || res=BAD
122
123test x"$res" = xOK
124
125if dt=`busybox date -d 012311332000.30 %+c`; then
126 echo "Expected this to fail with: \"date: invalid date '%+c'\"" >&2
127 exit 1
128fi