Skip to content

Commit

Permalink
Fix marshaling of date
Browse files Browse the repository at this point in the history
  • Loading branch information
ccremer committed Nov 18, 2022
1 parent d75c3a5 commit a0a81b1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion pkg/odoo/date.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package odoo
import (
"bytes"
"encoding/json"
"fmt"
"time"
)

Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion pkg/odoo/date_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit a0a81b1

Please sign in to comment.