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 <gsf@research.att.com> # 18# # 19######################################################################## 20# 21# addition date.dat test generator 22# 23 24now=2008-05-01+01:02:03 25regress=$1 26 27if [[ $regress ]] 28then printf $'%s\t\t\t\t\t%s\t%s\n' "SET" "NOW" "$now" 29fi 30 31while read d 32do 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 54done <<! 55 56now 57 58sunday 59monday 60tuesday 61wednesday 62thursday 63friday 64saturday 65 66this month 67last month 68next month 69 70this month 1st monday 71this month first monday 721st monday may 2008 73first monday may 2008 74 75this month 2nd monday 76this month second monday 772nd monday may 2008 78second monday may 2008 79 80this month 3rd monday 81this month third monday 823rd monday may 2008 83third monday may 2008 84 85this month 4th monday 86this month fourth monday 874th monday may 2008 88fourth monday may 2008 89 90this month 5th monday 91this month fifth monday 925th monday may 2008 93fifth monday may 2008 94 95this month 6th monday 96this month sixth monday 976th monday may 2008 98sixth monday may 2008 99 100this month nth monday 101this month final monday 102nth monday may 2008 103final monday may 2008 104 105last month first monday 106last month 1st monday 107last month second monday 108last month 2nd monday 109last month third monday 110last month 3rd monday 111last month fourth monday 112last month 4th monday 113last month final monday 114last month nth monday 115 116next month first monday 117next month 1st monday 118next month second monday 119next month 2nd monday 120next month third monday 121next month 3rd monday 122next month fourth monday 123next month 4th monday 124next month final monday 125next month nth monday 126 127! 128