diff --git a/leapseconds.awk b/leapseconds.awk index 652a45b..29416ae 100755 --- a/leapseconds.awk +++ b/leapseconds.awk @@ -65,18 +65,23 @@ BEGIN { last_lines = last_lines $0 "\n" } -/^#[$][ \t]/ { updated = $2 } -/^#[@][ \t]/ { expires = $2 } +/^#[$][ \t]/ { updated = int( $2 ) } # no CR +/^#[@][ \t]/ { expires = int( $2 ) } # no CR /^#/ { next } { + # Note: NIST uses CRLF line termination. If + # leap-seconds.list is transfered in binary mode + # "year" will have a CR at the end of its string + # which would generate: Leap\tYYYY\tMmm Dd ... + NTP_timestamp = $1 TAI_minus_UTC = $2 hash_mark = $3 one = $4 month = $5 - year = $6 + year = int( $6 ) # no more CR if (old_TAI_minus_UTC) { if (old_TAI_minus_UTC < TAI_minus_UTC) { sign = "23:59:60\t+" @@ -91,7 +96,7 @@ BEGIN { month = monthabbr[m] day = monthlen[m] day += m == 2 && year % 4 == 0 && (year % 100 != 0 || year % 400 == 0) - printf "Leap\t%s\t%s\t%s\t%s\tS\n", year, month, day, sign + printf "Leap\t%4d\t%s\t%s\t%s\tS\n", year, month, day, sign } old_TAI_minus_UTC = TAI_minus_UTC } @@ -104,7 +109,7 @@ END { print "" print "# POSIX timestamps for the data in this file:" - printf "#updated %s\n", updated - epoch_minus_NTP - printf "#expires %s\n", expires - epoch_minus_NTP + printf "#updated %d\n", updated - epoch_minus_NTP + printf "#expires %d\n", expires - epoch_minus_NTP printf "\n%s", last_lines }