Skip to content

Commit

Permalink
Add JSON methods to sqlite Time type
Browse files Browse the repository at this point in the history
  • Loading branch information
pglass authored and kenshaw committed May 1, 2023
1 parent c57bd10 commit 25b9c88
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions _examples/booktest/sqlite3/db.xo.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions templates/go/db.xo.go.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,16 @@ func (t *Time) Parse(s string) error {
return ErrInvalidTime(s)
}

// MarshalJSON satisfies the json.Marshaler interface.
func (t Time) MarshalJSON() ([]byte, error) {
return t.time.MarshalJSON()
}

// UnmarshalJSON satisfies the json.Unmarshaler interface.
func (t *Time) UnmarshalJSON(data []byte) error {
return t.time.UnmarshalJSON(data)
}

// TimestampFormats are the timestamp formats used by SQLite3 database drivers
// to store a time.Time in SQLite3.
//
Expand Down

0 comments on commit 25b9c88

Please sign in to comment.