diff --git a/pkg/odoo/date.go b/pkg/odoo/date.go index 644b9a4..2575c14 100644 --- a/pkg/odoo/date.go +++ b/pkg/odoo/date.go @@ -3,6 +3,7 @@ package odoo import ( "bytes" "encoding/json" + "fmt" "time" ) @@ -28,7 +29,7 @@ func (d *Date) MarshalJSON() ([]byte, error) { if d.IsZero() { return []byte("false"), nil } - return []byte(d.Format(DateTimeFormat)), nil + return []byte(fmt.Sprintf(`"%s"`, d.Format(DateTimeFormat))), nil } func (d *Date) UnmarshalJSON(b []byte) error { diff --git a/pkg/odoo/date_test.go b/pkg/odoo/date_test.go index e5aaac1..a3b5a35 100644 --- a/pkg/odoo/date_test.go +++ b/pkg/odoo/date_test.go @@ -52,7 +52,7 @@ func TestDate_MarshalJSON(t *testing.T) { }, "GivenTime_ThenReturnFormatted": { givenDate: Date{Time: time.Date(2021, 02, 03, 4, 5, 6, 0, time.UTC)}, - expectedOutput: "2021-02-03 04:05:06", + expectedOutput: `"2021-02-03 04:05:06"`, }, } for name, tc := range tests {