Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/cmd/tests/testdate.sh
1808 views
1
########################################################################
2
# #
3
# This software is part of the ast package #
4
# Copyright (c) 1999-2011 AT&T Intellectual Property #
5
# and is licensed under the #
6
# Eclipse Public License, Version 1.0 #
7
# by AT&T Intellectual Property #
8
# #
9
# A copy of the License is available at #
10
# http://www.eclipse.org/org/documents/epl-v10.html #
11
# (with md5 checksum b35adb5213ca9657e911e9befb180842) #
12
# #
13
# Information and Software Systems Research #
14
# AT&T Research #
15
# Florham Park NJ #
16
# #
17
# Glenn Fowler <[email protected]> #
18
# #
19
########################################################################
20
#
21
# addition date.dat test generator
22
#
23
24
now=2008-05-01+01:02:03
25
regress=$1
26
27
if [[ $regress ]]
28
then printf $'%s\t\t\t\t\t%s\t%s\n' "SET" "NOW" "$now"
29
fi
30
31
while read d
32
do if [[ $d ]]
33
then # printf $'%T %s\n' "$d" "$d"
34
if [[ $regress ]]
35
then width=${#d}
36
if (( width < 8 ))
37
then sep=$'\t\t\t\t\t'
38
elif (( width < 16 ))
39
then sep=$'\t\t\t\t'
40
elif (( width < 24 ))
41
then sep=$'\t\t\t'
42
elif (( width < 32 ))
43
then sep=$'\t\t'
44
else sep=$'\t'
45
fi
46
if [[ $d == +([a-z])day ]]
47
then printf $'%s%sNULL\t%s\n' "$d" "$sep" "$(date -s "$now $d" | tail -1)"
48
else printf $'%s%sNULL\t%s\n' "$d" "$sep" "$(date -s "$now" "$d" | tail -1)"
49
fi
50
else printf $'%s %s\n' "$(date -s "$now" "$d" | tail -1)" "$d"
51
fi
52
else printf $'\n'
53
fi
54
done <<!
55
56
now
57
58
sunday
59
monday
60
tuesday
61
wednesday
62
thursday
63
friday
64
saturday
65
66
this month
67
last month
68
next month
69
70
this month 1st monday
71
this month first monday
72
1st monday may 2008
73
first monday may 2008
74
75
this month 2nd monday
76
this month second monday
77
2nd monday may 2008
78
second monday may 2008
79
80
this month 3rd monday
81
this month third monday
82
3rd monday may 2008
83
third monday may 2008
84
85
this month 4th monday
86
this month fourth monday
87
4th monday may 2008
88
fourth monday may 2008
89
90
this month 5th monday
91
this month fifth monday
92
5th monday may 2008
93
fifth monday may 2008
94
95
this month 6th monday
96
this month sixth monday
97
6th monday may 2008
98
sixth monday may 2008
99
100
this month nth monday
101
this month final monday
102
nth monday may 2008
103
final monday may 2008
104
105
last month first monday
106
last month 1st monday
107
last month second monday
108
last month 2nd monday
109
last month third monday
110
last month 3rd monday
111
last month fourth monday
112
last month 4th monday
113
last month final monday
114
last month nth monday
115
116
next month first monday
117
next month 1st monday
118
next month second monday
119
next month 2nd monday
120
next month third monday
121
next month 3rd monday
122
next month fourth monday
123
next month 4th monday
124
next month final monday
125
next month nth monday
126
127
!
128
129