String serializes the current DateTime instance into a formatted UTC date string. The zero value is serialized to an empty string.
()
| 98 | // |
| 99 | // The zero value is serialized to an empty string. |
| 100 | func (d DateTime) String() string { |
| 101 | t := d.Time() |
| 102 | if t.IsZero() { |
| 103 | return "" |
| 104 | } |
| 105 | return t.UTC().Format(DefaultDateLayout) |
| 106 | } |
| 107 | |
| 108 | // MarshalJSON implements the [json.Marshaler] interface. |
| 109 | func (d DateTime) MarshalJSON() ([]byte, error) { |