-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdate2iso
executable file
·57 lines (52 loc) · 911 Bytes
/
date2iso
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
#!/usr/bin/env perl
# date2iso
# File ID: 35e0af3c-5d38-11df-8eb4-90e6ba3022ac
# Konverterer obskure dataformater til ISO-8601.
use strict;
use warnings;
my %mnd_str = (
'Jan' => '01',
'Feb' => '02',
'Mar' => '03',
'Apr' => '04',
'May' => '05',
'Jun' => '06',
'Jul' => '07',
'Aug' => '08',
'Sep' => '09',
'Oct' => '10',
'Nov' => '11',
'Dec' => '12'
);
while (<>) {
s/
(Mon|Tue|Wed|Thu|Fri|Sat|Sun)\s+
(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s+
(\d+)\s+
(\d\d:\d\d:\d\d)\s+
([A-Za-c]+\s+)?
(\d\d\d\d)
/
sprintf("%s %04u-%s-%02u %s%s",
$1,
$6,
$mnd_str{$2},
$3,
$4,
defined($5)
? " $5"
: "",
)
/eix;
s/
(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s+
(\d+)\s+
(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s+
(\d\d\d\d)\s+
(\d\d:\d\d:\d\d)
/
sprintf("%s %04u-%s-%02u %s", $1, $4, $mnd_str{$3}, $2, $5)
/eix;
print;
}
# vim: set noet :