Fix up time display format
[bus.git] / maxious-canberra-transit-feed / parse-times.pl
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
#!/usr/bin/perl
 
use strict;
 
my $first = 1;
my $prev_comment = 0;
while (<STDIN>) {
    if ($_ !~ /^\#/) {
        if (!$first && !$prev_comment) {
            print ",\n";
        } else {
            $first = 0;
            $prev_comment = 0;
        }
        chomp;
        my @times = split /\ +/;
        print "  [ ";
        my $first = 1;
        foreach (@times) {
            if (!$first) {
                print ", ";
            } else {
                $first = 0;
            }
            print $_;
        }
        print "]";
    } else {
        # yes, this conditional is loaded with assumptions...
        print ",\n" . $_;
        $prev_comment = 1;
    }
}