|
Packit |
67cb25 |
#!/bin/sh
|
|
Packit |
67cb25 |
# mdate-sh - get modification time of a file and pretty-print it
|
|
Packit |
67cb25 |
# Copyright (C) 1995 Software Foundation, Inc.
|
|
Packit |
67cb25 |
# Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, June 1995
|
|
Packit |
67cb25 |
#
|
|
Packit |
67cb25 |
# This program is free software; you can redistribute it and/or modify
|
|
Packit |
67cb25 |
# it under the terms of the GNU General Public License as published by
|
|
Packit |
67cb25 |
# the Free Software Foundation; either version 2, or (at your option)
|
|
Packit |
67cb25 |
# any later version.
|
|
Packit |
67cb25 |
#
|
|
Packit |
67cb25 |
# This program is distributed in the hope that it will be useful,
|
|
Packit |
67cb25 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
67cb25 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit |
67cb25 |
# GNU General Public License for more details.
|
|
Packit |
67cb25 |
#
|
|
Packit |
67cb25 |
# You should have received a copy of the GNU General Public License
|
|
Packit |
67cb25 |
# along with this program; if not, write to the Free Software
|
|
Packit |
67cb25 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
# Prevent date giving response in another language.
|
|
Packit |
67cb25 |
LANG=C
|
|
Packit |
67cb25 |
export LANG
|
|
Packit |
67cb25 |
LC_ALL=C
|
|
Packit |
67cb25 |
export LC_ALL
|
|
Packit |
67cb25 |
LC_TIME=C
|
|
Packit |
67cb25 |
export LC_TIME
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
# Get the extended ls output of the file.
|
|
Packit |
67cb25 |
if ls -L /dev/null 1>/dev/null 2>&1; then
|
|
Packit |
67cb25 |
set - `ls -L -l $1`
|
|
Packit |
67cb25 |
else
|
|
Packit |
67cb25 |
set - `ls -l $1`
|
|
Packit |
67cb25 |
fi
|
|
Packit |
67cb25 |
# The month is at least the fourth argument.
|
|
Packit |
67cb25 |
# (3 shifts here, the next inside the loop)
|
|
Packit |
67cb25 |
shift
|
|
Packit |
67cb25 |
shift
|
|
Packit |
67cb25 |
shift
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
# Find the month. Next argument is day, followed by the year or time.
|
|
Packit |
67cb25 |
month=
|
|
Packit |
67cb25 |
until test $month
|
|
Packit |
67cb25 |
do
|
|
Packit |
67cb25 |
shift
|
|
Packit |
67cb25 |
case $1 in
|
|
Packit |
67cb25 |
Jan) month=January; nummonth=1;;
|
|
Packit |
67cb25 |
Feb) month=February; nummonth=2;;
|
|
Packit |
67cb25 |
Mar) month=March; nummonth=3;;
|
|
Packit |
67cb25 |
Apr) month=April; nummonth=4;;
|
|
Packit |
67cb25 |
May) month=May; nummonth=5;;
|
|
Packit |
67cb25 |
Jun) month=June; nummonth=6;;
|
|
Packit |
67cb25 |
Jul) month=July; nummonth=7;;
|
|
Packit |
67cb25 |
Aug) month=August; nummonth=8;;
|
|
Packit |
67cb25 |
Sep) month=September; nummonth=9;;
|
|
Packit |
67cb25 |
Oct) month=October; nummonth=10;;
|
|
Packit |
67cb25 |
Nov) month=November; nummonth=11;;
|
|
Packit |
67cb25 |
Dec) month=December; nummonth=12;;
|
|
Packit |
67cb25 |
esac
|
|
Packit |
67cb25 |
done
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
day=$2
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
# Here we have to deal with the problem that the ls output gives either
|
|
Packit |
67cb25 |
# the time of day or the year.
|
|
Packit |
67cb25 |
case $3 in
|
|
Packit |
67cb25 |
*:*) set `date`; eval year=\$$#
|
|
Packit |
67cb25 |
case $2 in
|
|
Packit |
67cb25 |
Jan) nummonthtod=1;;
|
|
Packit |
67cb25 |
Feb) nummonthtod=2;;
|
|
Packit |
67cb25 |
Mar) nummonthtod=3;;
|
|
Packit |
67cb25 |
Apr) nummonthtod=4;;
|
|
Packit |
67cb25 |
May) nummonthtod=5;;
|
|
Packit |
67cb25 |
Jun) nummonthtod=6;;
|
|
Packit |
67cb25 |
Jul) nummonthtod=7;;
|
|
Packit |
67cb25 |
Aug) nummonthtod=8;;
|
|
Packit |
67cb25 |
Sep) nummonthtod=9;;
|
|
Packit |
67cb25 |
Oct) nummonthtod=10;;
|
|
Packit |
67cb25 |
Nov) nummonthtod=11;;
|
|
Packit |
67cb25 |
Dec) nummonthtod=12;;
|
|
Packit |
67cb25 |
esac
|
|
Packit |
67cb25 |
# For the first six month of the year the time notation can also
|
|
Packit |
67cb25 |
# be used for files modified in the last year.
|
|
Packit |
67cb25 |
if (expr $nummonth \> $nummonthtod) > /dev/null;
|
|
Packit |
67cb25 |
then
|
|
Packit |
67cb25 |
year=`expr $year - 1`
|
|
Packit |
67cb25 |
fi;;
|
|
Packit |
67cb25 |
*) year=$3;;
|
|
Packit |
67cb25 |
esac
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
# The result.
|
|
Packit |
67cb25 |
echo $day $month $year
|