#!/usr/bin/perl -w

use strict;

our $Datestamp = "";

sub month_to_num($) {
    my %months = (
        "Jan" => 1,
        "Feb" => 2,
        "Mar" => 3,
        "Apr" => 4,
        "May" => 5,
        "Jun" => 6,
        "Jul" => 7,
        "Aug" => 8,
        "Sep" => 9,
        "Oct" => 10,
        "Nov" => 11,
        "Dec" => 12
    );
    my $month = shift;
    return $months{$month};
}

my $linenum = 0;
while (<STDIN>) {
    $linenum++;
    # --- Day changed Thu Aug 02 2012
    # --- Log opened Wed Aug 01 19:20:39 2012
    if(/^--- Day changed (\w+)\s+(\w+)\s+(\d+)\s+(\d+)/ or /^--- Log \w+ (\w+)\s+(\w+)\s+(\d+)\s+\d+:\d+:\d+\s+(\d+)/) {
        my ($day, $month, $dom, $year) = ($1, $2, $3, $4);
        # print "$1 $2 $3 $4 ";
        $Datestamp = sprintf "%04d-%02d-%02d", $year, month_to_num($month), $dom;
        # printf "%04d-%02d-%02d", $year, month_to_num($month), $dom;
        # print $Datestamp;
        # print "\n";
    }
    elsif(/^(\d\d):(\d\d):(\d\d)([< *-].*)/) {
        my ($hour, $min, $sec, $rest) = ($1, $2, $3, $4);
        # printf "%s %02d:%02d:%02d%s\n", $Datestamp, $hour, $min, $sec, $rest;
        $_ = sprintf "%s %02d:%02d:%02d%s\n", $Datestamp, $hour, $min, $sec, $rest;
        # s/^\d\d:\d\d:\d\d/
    }
    # else {
        # warn "ERROR on line $linenum\n";
        # }
    print $_;
}
