123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224 |
- scriptversion=2016-01-11.22; # UTC
- if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
- emulate sh
- NULLCMD=:
- # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
- # is contrary to our usage. Disable this feature.
- alias -g '${1+"$@"}'='"$@"'
- setopt NO_GLOB_SUBST
- fi
- case $1 in
- '')
- echo "$0: No file. Try '$0 --help' for more information." 1>&2
- exit 1;
- ;;
- -h | --h*)
- cat <<\EOF
- Usage: mdate-sh [--help] [--version] FILE
- Pretty-print the modification day of FILE, in the format:
- 1 January 1970
- Report bugs to <bug-automake@gnu.org>.
- EOF
- exit $?
- ;;
- -v | --v*)
- echo "mdate-sh $scriptversion"
- exit $?
- ;;
- esac
- error ()
- {
- echo "$0: $1" >&2
- exit 1
- }
- LANG=C
- export LANG
- LC_ALL=C
- export LC_ALL
- LC_TIME=C
- export LC_TIME
- if test "${TIME_STYLE+set}" = set; then
- TIME_STYLE=posix-long-iso
- export TIME_STYLE
- fi
- save_arg1=$1
- if ls -L /dev/null 1>/dev/null 2>&1; then
- ls_command='ls -L -l -d'
- else
- ls_command='ls -l -d'
- fi
- if ls -n /dev/null 1>/dev/null 2>&1; then
- ls_command="$ls_command -n"
- fi
- set x`$ls_command /`
- month=
- command=
- until test $month
- do
- test $# -gt 0 || error "failed parsing '$ls_command /' output"
- shift
- # Add another shift to the command.
- command="$command shift;"
- case $1 in
- Jan) month=January; nummonth=1;;
- Feb) month=February; nummonth=2;;
- Mar) month=March; nummonth=3;;
- Apr) month=April; nummonth=4;;
- May) month=May; nummonth=5;;
- Jun) month=June; nummonth=6;;
- Jul) month=July; nummonth=7;;
- Aug) month=August; nummonth=8;;
- Sep) month=September; nummonth=9;;
- Oct) month=October; nummonth=10;;
- Nov) month=November; nummonth=11;;
- Dec) month=December; nummonth=12;;
- esac
- done
- test -n "$month" || error "failed parsing '$ls_command /' output"
- set dummy x`eval "$ls_command \"\\\$save_arg1\""`
- eval $command
- case $2 in
- Jan) month=January; nummonth=1;;
- Feb) month=February; nummonth=2;;
- Mar) month=March; nummonth=3;;
- Apr) month=April; nummonth=4;;
- May) month=May; nummonth=5;;
- Jun) month=June; nummonth=6;;
- Jul) month=July; nummonth=7;;
- Aug) month=August; nummonth=8;;
- Sep) month=September; nummonth=9;;
- Oct) month=October; nummonth=10;;
- Nov) month=November; nummonth=11;;
- Dec) month=December; nummonth=12;;
- esac
- case $3 in
- ???*) day=$1;;
- *) day=$3; shift;;
- esac
- case $3 in
- *:*) set `date`; eval year=\$$#
- case $2 in
- Jan) nummonthtod=1;;
- Feb) nummonthtod=2;;
- Mar) nummonthtod=3;;
- Apr) nummonthtod=4;;
- May) nummonthtod=5;;
- Jun) nummonthtod=6;;
- Jul) nummonthtod=7;;
- Aug) nummonthtod=8;;
- Sep) nummonthtod=9;;
- Oct) nummonthtod=10;;
- Nov) nummonthtod=11;;
- Dec) nummonthtod=12;;
- esac
- # For the first six month of the year the time notation can also
- # be used for files modified in the last year.
- if (expr $nummonth \> $nummonthtod) > /dev/null;
- then
- year=`expr $year - 1`
- fi;;
- *) year=$3;;
- esac
- echo $day $month $year
|