Reject leap seconds to prevent year overflow (#1019)
Go's time.Date() normalizes leap seconds (second=60) by adding 1 minute. When parsing the maximum valid TOML date 9999-12-31 23:59:60z, this causes the year to overflow to 10000, which exceeds the valid TOML year range (0000-9999) and breaks round-trip serialization. The fix rejects leap seconds (second > 59) during parsing. This is consistent with the resolution of issue #913 which determined that emitting an error is less surprising than silently normalizing leap seconds. Fixes #1015 Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
+1
-1
@@ -45,7 +45,7 @@ func (d *LocalDate) UnmarshalText(b []byte) error {
|
||||
type LocalTime struct {
|
||||
Hour int // Hour of the day: [0; 24[
|
||||
Minute int // Minute of the hour: [0; 60[
|
||||
Second int // Second of the minute: [0; 60[
|
||||
Second int // Second of the minute: [0; 59]
|
||||
Nanosecond int // Nanoseconds within the second: [0, 1000000000[
|
||||
Precision int // Number of digits to display for Nanosecond.
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user