CustomDateTime
The CustomDateTime struct wraps Go's time.Time and handles CBOR encoding with tag 12 as specified by SurrealDB. It preserves nanosecond precision and stores datetimes as a [seconds, nanoseconds] pair.
Package: github.com/surrealdb/surrealdb.go/pkg/models
Source: pkg/models/datetime.go
Definition
CustomDateTime embeds time.Time, so all standard time.Time methods are available directly.
Methods
.String()
Returns the datetime formatted as "2006-01-02T15:04:05Z" in UTC.
Returns: string
.SurrealString()
Returns the SurrealQL representation: <datetime> '2006-01-02T15:04:05Z'.
Returns: string
.IsZero()
Returns true if the datetime is nil or the zero time.
Returns: bool
Usage
Zero-valued CustomDateTime is encoded as CBOR tag 6 (NONE).
See Also
RecordID for the record identifier type
Duration for the duration type
Value types for the full type mapping
Data manipulation for using datetime values in CRUD operations
SurrealQL datetime type for the underlying data model