std sh til-kron
[sunny256-utils.git] / tosec
blob55a06b0cf7313e3c2f0eddf5265d12bece6fe489
1 #!/usr/bin/env perl
3 #===========================================================================
4 # tosec
5 # File ID: b1b05618-5d46-11df-9330-90e6ba3022ac
6 # Mottar datoer på kommandolinja og konverterer dem til sekunder siden 1970.
7 # Format: ååååmmddTttmmss med valgfri Z på slutten for GMT
8 #===========================================================================
10 use strict;
11 use warnings;
12 use Time::Local;
14 foreach(@ARGV) {
15 if (/((?:19|20)\d\d)([01]\d)([0-3]\d)T([0-2]\d)([0-5]\d)([0-6]\d)(Z?)/) {
16 if ($7 eq "Z") {
17 print(timegm($6, $5, $4, $3, $2-1, $1));
18 } else {
19 print(timelocal($6, $5, $4, $3, $2-1, $1));
22 print("\n");