bpakk: Change `-w` option to `-s`/`--size`
[sunny256-utils.git] / ampm
blobe39af0ade670ae816844b8c42f7f54b3eac66ee7
1 #!/usr/bin/env perl
3 # ampm
4 # File ID: 18c94c16-5d37-11df-b31a-90e6ba3022ac
5 # Konverterer fra helsikes am/pm til 24-timers klokke
7 use strict;
8 use warnings;
10 while (<>) {
12 # 12:00am til 12:59am
13 # Trekk fra 12 timer
14 # 12:59am = 00:59
15 s/(12)(:[0-5][0-9]:[0-5][0-9]) ?am/sprintf("%02u%s", $1-12, $2)/gei;
16 s/(12)(:[0-5][0-9]) ?am/sprintf("%02u%s", $1-12, $2)/gei;
18 # 01:00pm til 11:59pm
19 # Legg til 12 timer
20 # 10:59pm = 22:59
21 s/0?([1-9]|10|11)(:[0-5][0-9]:[0-5][0-9]) ?pm/sprintf("%02u%s", $1+12, $2)/gei;
22 s/0?([1-9]|10|11)(:[0-5][0-9]) ?pm/sprintf("%02u%s", $1+12, $2)/gei;
24 # Resten av driten stripper vi bort am/pm fra
25 s/0?([1-9]|10|11|12)(:[0-5][0-9]:[0-5][0-9]) ?(am|pm)/$1$2/gi;
26 s/0?([1-9]|10|11|12)(:[0-5][0-9]) ?(am|pm)/$1$2/gi;
28 print;