File: cdcat-datefix.pl

package info (click to toggle)
cdcat 0.99-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 2,124 kB
  • ctags: 1,574
  • sloc: cpp: 18,143; makefile: 58; perl: 37; xml: 6
file content (37 lines) | stat: -rwxr-xr-x 699 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/perl -w

# 2004-07-23
# Marko Crnic <paranoid@nymphomatic.org>
# http://www.nymphomatic.org/~paranoid/
#
# Fix date format in .hcf files (gzipped xml).
# .hcf is used by CdCat (http://cdcat.sf.net).

use Compress::Zlib ;

($a, $b) = @ARGV;

if(!$a || !$b)
{ 
	print "Usage: $0 infile.hcf outfile.hcf\n";
	exit 1;
}

$gz = gzopen("$a", "rb");
$out = gzopen("$b", "wb");

while($gz->gzreadline($lajna))
{
	if($lajna =~ /time="(.*)\.(.*) (\d+):(\d+) (\d{4})"/)
	{
		$hr = $3;
		$mn = $4;
		if($3 < 10) { $hr = "0$3"; }
		if($4 < 10) { $mn = "0$4"; }
		$lajna =~ s/time="(.*)\.(.*) (\d+):(\d+) (\d{4})"/time="$1 $2 $hr:$mn $5"/;
	}
	$out->gzwrite($lajna);
}

$out->gzclose();
$gz->gzclose();