1*75f6d617Schristos#!/bin/sh 2*75f6d617Schristos# Get modification time of a file or directory and pretty-print it. 3*75f6d617Schristos# Copyright 1995, 1996, 1997 Free Software Foundation, Inc. 4*75f6d617Schristos# written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, June 1995 5*75f6d617Schristos# 6*75f6d617Schristos# This program is free software; you can redistribute it and/or modify 7*75f6d617Schristos# it under the terms of the GNU General Public License as published by 8*75f6d617Schristos# the Free Software Foundation; either version 2, or (at your option) 9*75f6d617Schristos# any later version. 10*75f6d617Schristos# 11*75f6d617Schristos# This program is distributed in the hope that it will be useful, 12*75f6d617Schristos# but WITHOUT ANY WARRANTY; without even the implied warranty of 13*75f6d617Schristos# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14*75f6d617Schristos# GNU General Public License for more details. 15*75f6d617Schristos# 16*75f6d617Schristos# You should have received a copy of the GNU General Public License 17*75f6d617Schristos# along with this program; if not, write to the Free Software Foundation, 18*75f6d617Schristos# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19*75f6d617Schristos 20*75f6d617Schristos# As a special exception to the GNU General Public License, if you 21*75f6d617Schristos# distribute this file as part of a program that contains a 22*75f6d617Schristos# configuration script generated by Autoconf, you may include it under 23*75f6d617Schristos# the same distribution terms that you use for the rest of that program. 24*75f6d617Schristos 25*75f6d617Schristos# Prevent date giving response in another language. 26*75f6d617SchristosLANG=C 27*75f6d617Schristosexport LANG 28*75f6d617SchristosLC_ALL=C 29*75f6d617Schristosexport LC_ALL 30*75f6d617SchristosLC_TIME=C 31*75f6d617Schristosexport LC_TIME 32*75f6d617Schristos 33*75f6d617Schristos# Get the extended ls output of the file or directory. 34*75f6d617Schristos# On HPUX /bin/sh, "set" interprets "-rw-r--r--" as options, so the "x" below. 35*75f6d617Schristosif ls -L /dev/null 1>/dev/null 2>&1; then 36*75f6d617Schristos set - x`ls -L -l -d $1` 37*75f6d617Schristoselse 38*75f6d617Schristos set - x`ls -l -d $1` 39*75f6d617Schristosfi 40*75f6d617Schristos# The month is at least the fourth argument 41*75f6d617Schristos# (3 shifts here, the next inside the loop). 42*75f6d617Schristosshift 43*75f6d617Schristosshift 44*75f6d617Schristosshift 45*75f6d617Schristos 46*75f6d617Schristos# Find the month. Next argument is day, followed by the year or time. 47*75f6d617Schristosmonth= 48*75f6d617Schristosuntil test $month 49*75f6d617Schristosdo 50*75f6d617Schristos shift 51*75f6d617Schristos case $1 in 52*75f6d617Schristos Jan) month=January; nummonth=1;; 53*75f6d617Schristos Feb) month=February; nummonth=2;; 54*75f6d617Schristos Mar) month=March; nummonth=3;; 55*75f6d617Schristos Apr) month=April; nummonth=4;; 56*75f6d617Schristos May) month=May; nummonth=5;; 57*75f6d617Schristos Jun) month=June; nummonth=6;; 58*75f6d617Schristos Jul) month=July; nummonth=7;; 59*75f6d617Schristos Aug) month=August; nummonth=8;; 60*75f6d617Schristos Sep) month=September; nummonth=9;; 61*75f6d617Schristos Oct) month=October; nummonth=10;; 62*75f6d617Schristos Nov) month=November; nummonth=11;; 63*75f6d617Schristos Dec) month=December; nummonth=12;; 64*75f6d617Schristos esac 65*75f6d617Schristosdone 66*75f6d617Schristos 67*75f6d617Schristosday=$2 68*75f6d617Schristos 69*75f6d617Schristos# Here we have to deal with the problem that the ls output gives either 70*75f6d617Schristos# the time of day or the year. 71*75f6d617Schristoscase $3 in 72*75f6d617Schristos *:*) set `date`; eval year=\$$# 73*75f6d617Schristos case $2 in 74*75f6d617Schristos Jan) nummonthtod=1;; 75*75f6d617Schristos Feb) nummonthtod=2;; 76*75f6d617Schristos Mar) nummonthtod=3;; 77*75f6d617Schristos Apr) nummonthtod=4;; 78*75f6d617Schristos May) nummonthtod=5;; 79*75f6d617Schristos Jun) nummonthtod=6;; 80*75f6d617Schristos Jul) nummonthtod=7;; 81*75f6d617Schristos Aug) nummonthtod=8;; 82*75f6d617Schristos Sep) nummonthtod=9;; 83*75f6d617Schristos Oct) nummonthtod=10;; 84*75f6d617Schristos Nov) nummonthtod=11;; 85*75f6d617Schristos Dec) nummonthtod=12;; 86*75f6d617Schristos esac 87*75f6d617Schristos # For the first six month of the year the time notation can also 88*75f6d617Schristos # be used for files modified in the last year. 89*75f6d617Schristos if (expr $nummonth \> $nummonthtod) > /dev/null; 90*75f6d617Schristos then 91*75f6d617Schristos year=`expr $year - 1` 92*75f6d617Schristos fi;; 93*75f6d617Schristos *) year=$3;; 94*75f6d617Schristosesac 95*75f6d617Schristos 96*75f6d617Schristos# The result. 97*75f6d617Schristosecho $day $month $year 98