Start new section for post-1.0 changes.
[bpt/guile.git] / mdate-sh
CommitLineData
3f46d959
MG
1#!/bin/sh
2# mdate-sh - get modification time of a file and pretty-print it
3# Copyright (C) 1995 Software Foundation, Inc.
4# Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, June 1995
5#
6# This program is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 2, or (at your option)
9# any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program; if not, write to the Free Software
18# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
20# Prevent date giving response in another language.
21LANG=C
22export LANG
23LC_ALL=C
24export LC_ALL
25LC_TIME=C
26export LC_TIME
27
28# Get the extended ls output of the file.
29if ls -L /dev/null 1>/dev/null 2>&1; then
30 set - `ls -L -l $1`
31else
32 set - `ls -l $1`
33fi
34# The month is at least the fourth argument.
35# (3 shifts here, the next inside the loop)
36shift
37shift
38shift
39
40# Find the month. Next argument is day, followed by the year or time.
41month=
42until test $month
43do
44 shift
45 case $1 in
46 Jan) month=January; nummonth=1;;
47 Feb) month=February; nummonth=2;;
48 Mar) month=March; nummonth=3;;
49 Apr) month=April; nummonth=4;;
50 May) month=May; nummonth=5;;
51 Jun) month=June; nummonth=6;;
52 Jul) month=July; nummonth=7;;
53 Aug) month=August; nummonth=8;;
54 Sep) month=September; nummonth=9;;
55 Oct) month=October; nummonth=10;;
56 Nov) month=November; nummonth=11;;
57 Dec) month=December; nummonth=12;;
58 esac
59done
60
61day=$2
62
63# Here we have to deal with the problem that the ls output gives either
64# the time of day or the year.
65case $3 in
66 *:*) set `date`; eval year=\$$#
67 case $2 in
68 Jan) nummonthtod=1;;
69 Feb) nummonthtod=2;;
70 Mar) nummonthtod=3;;
71 Apr) nummonthtod=4;;
72 May) nummonthtod=5;;
73 Jun) nummonthtod=6;;
74 Jul) nummonthtod=7;;
75 Aug) nummonthtod=8;;
76 Sep) nummonthtod=9;;
77 Oct) nummonthtod=10;;
78 Nov) nummonthtod=11;;
79 Dec) nummonthtod=12;;
80 esac
81 # For the first six month of the year the time notation can also
82 # be used for files modified in the last year.
83 if (expr $nummonth \> $nummonthtod) > /dev/null;
84 then
85 year=`expr $year - 1`
86 fi;;
87 *) year=$3;;
88esac
89
90# The result.
91echo $day $month $year