Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encode: Follow RFC3339 spec for LocalTime #632

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion localtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (d LocalDateTime) AsTime(zone *time.Location) time.Time {

// String returns RFC 3339 representation of d.
func (d LocalDateTime) String() string {
return d.LocalDate.String() + " " + d.LocalTime.String()
return d.LocalDate.String() + "T" + d.LocalTime.String()
}

// MarshalText returns RFC 3339 representation of d.
Expand Down
4 changes: 2 additions & 2 deletions localtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func TestLocalDateTime_String(t *testing.T) {
toml.LocalDate{2021, 6, 8},
toml.LocalTime{20, 12, 1, 2},
}
require.Equal(t, "2021-06-08 20:12:01.000000002", d.String())
require.Equal(t, "2021-06-08T20:12:01.000000002", d.String())
}

func TestLocalDateTime_MarshalText(t *testing.T) {
Expand All @@ -87,7 +87,7 @@ func TestLocalDateTime_MarshalText(t *testing.T) {
}
b, err := d.MarshalText()
require.NoError(t, err)
require.Equal(t, []byte("2021-06-08 20:12:01.000000002"), b)
require.Equal(t, []byte("2021-06-08T20:12:01.000000002"), b)
}

func TestLocalDateTime_UnmarshalMarshalText(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion toml_testgen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,6 @@ func TestTOMLTest_Valid_Datetime_LocalTime(t *testing.T) {
}

func TestTOMLTest_Valid_Datetime_Local(t *testing.T) {
t.Skip("FIXME")
input := "local = 1987-07-05T17:45:00\nmilli = 1977-12-21T10:32:00.555\nspace = 1987-07-05 17:45:00\n"
jsonRef := "{\n \"local\": {\n \"type\": \"datetime-local\",\n \"value\": \"1987-07-05T17:45:00\"\n },\n \"milli\": {\n \"type\": \"datetime-local\",\n \"value\": \"1977-12-21T10:32:00.555\"\n },\n \"space\": {\n \"type\": \"datetime-local\",\n \"value\": \"1987-07-05T17:45:00\"\n }\n}\n"
testgenValid(t, input, jsonRef)
Expand Down