1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
|
#!/bin/csh -f
#>
#> CODE-DATE - turn the current date into a nice version number for codes
#>
#> Usage: code-date [-h] [-d] [-u] [-f mmddyy|mdy ]
#>
#> Options:
#> -h Help package
#>
#> -d Use dash (-) for date separator. Default (.)
#> -u Use underscore (_) for date separator. Default (.)
#>
#> -f mmddyy Select the order of the mm-month, dd-day and
#> -f mdy yy-year. Default mmddyy (mdy).
#>
#>
# We would do this on a system with "real" up to date software
#
# /bin/date +%m.%d.%y | sed 's/^0//' | sed 's/\.0/\./'
#
# On rotten old crufty systems we have to do this
#
#
# Modification History:
# 07-21-95 Jan Moura, LLNL: Extended prolog/Help package.
####################
#
# see PCD for the reason for this
set Here = `pwd` ; cd ; set RealHome = `pwd` ; cd $Here ; unset $Here
set Base = `pwd | sed "s|$RealHome|$home|"`
set HelpCode = $Base/$0
set help = "FALSE"
set Separ = "."
set Format = "mmddyy"
while ($#argv > 0)
switch ($argv[1])
case -h:
set help = "TRUE"
breaksw
case -d:
set Separ = "-"
breaksw
case -u:
set Separ = "_"
breaksw
case -f:
set Format = $argv[2]
shift
breaksw
default:
set help = "TRUE"
endsw
shift
end
if ($help == "TRUE") then
goto Help
endif
set Raw = `date`
set Month = $Raw[2]
set Day = $Raw[3]
if ($#Raw == 5) then
set Year = `echo $Raw[5] | awk '{print $1 - 1900}'`
else
set Year = `echo $Raw[6] | awk '{print $1 - 1900}'`
endif
switch ($Month)
case "Jan" :
set Month = 1
breaksw
case "Feb" :
set Month = 2
breaksw
case "Mar" :
set Month = 3
breaksw
case "Apr" :
set Month = 4
breaksw
case "May" :
set Month = 5
breaksw
case "Jun" :
set Month = 6
breaksw
case "Jul" :
set Month = 7
breaksw
case "Aug" :
set Month = 8
breaksw
case "Sep" :
set Month = 9
breaksw
case "Oct" :
set Month = 10
breaksw
case "Nov" :
set Month = 11
breaksw
case "Dec" :
set Month = 12
breaksw
endsw
if ($Format == "mmddyy" || $Format == "mdy") then
echo "$Month$Separ$Day$Separ$Year"
else if ($Format == "yymmdd" || $Format == "ymd") then
echo "$Year$Separ$Month$Separ$Day"
else if ($Format == "yyddmm" || $Format == "ydm") then
echo "$Year$Separ$Day$Separ$Month"
else if ($Format == "mmyydd" || $Format == "myd") then
echo "$Month$Separ$Year$Separ$Day"
else if ($Format == "ddmmyy" || $Format == "dmy") then
echo "$Day$Separ$Month$Separ$Year"
else if ($Format == "ddyymm" || $Format == "dym") then
echo "$Day$Separ$Year$Separ$Month"
else
goto Help
endif
exit($status)
Help:
awk '($1 == "#>") {print}' $HelpCode #Print Usage:
exit(1)
|