243
|
1 #!/usr/bin/perl -w
|
|
2 #
|
|
3 # usage: conv_log_dates.pl historyfile.old > historyfile.new
|
|
4 # Convert the dates to the new logfile format (mcabber v. >= 0.6.1)
|
|
5 #
|
|
6 # See histolog.c for the mcabber format.
|
|
7 #
|
|
8 # MiKael, 2005/06/14
|
|
9
|
|
10 use strict;
|
|
11
|
|
12 my $line;
|
|
13 my $linesleft = 0;
|
|
14
|
|
15 while ($line = <>) {
|
|
16 if ($linesleft) {
|
|
17 print $line;
|
|
18 $linesleft--;
|
|
19 next;
|
|
20 }
|
|
21 my $type = substr($line, 0, 2);
|
|
22 my $off_format = 0;
|
|
23 my $date;
|
|
24
|
|
25 if (substr($line, 11, 1) eq "T") {
|
|
26 $off_format = 8; # Offset
|
|
27 }
|
|
28
|
|
29 if ($off_format) {
|
|
30 # Already using the new format, nothing to do
|
|
31 $date = substr($line, 3, 18);
|
|
32 } else {
|
|
33 # Date conversion to iso8601
|
|
34 my ($ss,$mm,$hh,$DD,$MM,$YYYY) = gmtime(substr($line, 3, 10));
|
|
35 $date = sprintf "%04d%02d%02dT%02d:%02d:%02dZ",
|
|
36 $YYYY+1900, $MM+1,$DD,$hh,$mm,$ss;
|
|
37 }
|
|
38 $linesleft = substr($line, 14 + $off_format, 3);
|
|
39 $line = substr($line, 14 + $off_format);
|
|
40
|
|
41 print $type." ".$date." ".$line;
|
|
42
|
|
43 # Is there something better to cast to integer?
|
|
44 $linesleft = 0 + $linesleft;
|
|
45 }
|
|
46
|
|
47 # vim:set sw=2 sts=2 et si cinoptions="":
|