diff --git a/nulltime.go b/nulltime.go index 167a182..ab0bcea 100644 --- a/nulltime.go +++ b/nulltime.go @@ -106,8 +106,8 @@ func (n *Time) UnmarshalJSON(b []byte) error { return nil } -func (n Time) MarshalText() ([]byte, error) { - if n.Valid { +func (n *Time) MarshalText() ([]byte, error) { + if n != nil && n.Valid { location, err := time.LoadLocation(n.Timezone) if err != nil { location = time.UTC @@ -117,8 +117,8 @@ func (n Time) MarshalText() ([]byte, error) { return json.Marshal(nil) } -func (n Time) MarshalJSON() ([]byte, error) { - if n.Valid { +func (n *Time) MarshalJSON() ([]byte, error) { + if n != nil && n.Valid { location, err := time.LoadLocation(n.Timezone) if err != nil { location = time.UTC