xref: /386bsd/usr/src/usr.bin/groff/mdate.sh (revision a2142627)
1#! /bin/sh
2
3# Print the modification date of $1 `nicely'.
4
5# Don't want foreign dates.
6
7LANGUAGE=
8
9
10(date;
11if ls -L /dev/null 1>/dev/null 2>&1; then ls -L -l $1; else ls -l $1; fi
12) | awk '
13BEGIN {
14	full["Jan"] = "January"; number["Jan"] = 1;
15	full["Feb"] = "February"; number["Feb"] = 2;
16	full["Mar"] = "March"; number["Mar"] = 3;
17	full["Apr"] = "April"; number["Apr"] = 4;
18	full["May"] = "May"; number["May"] = 5;
19	full["Jun"] = "June"; number["Jun"] = 6;
20	full["Jul"] = "July"; number["Jul"] = 7;
21	full["Aug"] = "August"; number["Aug"] = 8;
22	full["Sep"] = "September"; number["Sep"] = 9;
23	full["Oct"] = "October"; number["Oct"] = 10;
24	full["Nov"] = "November"; number["Nov"] = 11;
25	full["Dec"] = "December"; number["Dec"] = 12;
26}
27
28NR == 1 {
29	month = $2;
30	year = $NF;
31}
32
33NR == 2 {
34	if ($(NF-1) ~ /:/) {
35		if (number[$(NF-3)] > number[month])
36			year--;
37	}
38	else
39		year = $(NF-1);
40	print $(NF-2), full[$(NF-3)], year
41}'
42