feat: make seconds optional in datetime and time values
TOML v1.1.0 allows times to be specified as HH:MM without the seconds component (previously HH:MM:SS was required). This applies to local times, local datetimes, and offset datetimes.
This commit is contained in:
@@ -67,6 +67,13 @@ func TestLocalTime_UnmarshalMarshalText(t *testing.T) {
|
||||
assert.Error(t, err)
|
||||
}
|
||||
|
||||
func TestLocalTime_UnmarshalText_WithoutSeconds(t *testing.T) {
|
||||
d := toml.LocalTime{}
|
||||
err := d.UnmarshalText([]byte("14:15"))
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, toml.LocalTime{14, 15, 0, 0, 0}, d)
|
||||
}
|
||||
|
||||
func TestLocalTime_RoundTrip(t *testing.T) {
|
||||
var d struct{ A toml.LocalTime }
|
||||
err := toml.Unmarshal([]byte("a=20:12:01.500"), &d)
|
||||
|
||||
Reference in New Issue
Block a user