summaryrefslogtreecommitdiff
path: root/mdate.sh
blob: 984379fc7dbaaf58b64bc79c914c38bdce32d6e2 (plain)
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
#! /bin/sh
#
# Copyright (C) 1991, 1992, 2001
#   Free Software Foundation, Inc.
# 
# This file is part of groff.
# 
# groff is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 2, or (at your option) any later
# version.
# 
# groff is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# for more details.
# 
# You should have received a copy of the GNU General Public License along
# with groff; see the file COPYING.  If not, write to the Free Software
# Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA.
#
# Print the modification date of $1 `nicely'.

# Don't want foreign dates.

LANGUAGE=
LC_ALL=C; export LC_ALL


(date;
if ls -L /dev/null 1>/dev/null 2>&1; then ls -L -l $1; else ls -l $1; fi
) | awk '
BEGIN {
	full["Jan"] = "January"; number["Jan"] = 1;
	full["Feb"] = "February"; number["Feb"] = 2;
	full["Mar"] = "March"; number["Mar"] = 3;
	full["Apr"] = "April"; number["Apr"] = 4;
	full["May"] = "May"; number["May"] = 5;
	full["Jun"] = "June"; number["Jun"] = 6;
	full["Jul"] = "July"; number["Jul"] = 7;
	full["Aug"] = "August"; number["Aug"] = 8;
	full["Sep"] = "September"; number["Sep"] = 9;
	full["Oct"] = "October"; number["Oct"] = 10;
	full["Nov"] = "November"; number["Nov"] = 11;
	full["Dec"] = "December"; number["Dec"] = 12;
}

NR == 1 {
	month = $2;
	year = $NF;
}

NR == 2 {
	if ($(NF-1) ~ /:/) {
		if (number[$(NF-3)] > number[month])
			year--;
	}
	else
		year = $(NF-1);
	print $(NF-2), full[$(NF-3)], year
}'