DateTime represents a [time.Time] instance in UTC that is wrapped and serialized using the app default date layout.

Hierarchy

Implemented by

Methods

  • AddDate returns a new DateTime based on the current one + duration.

    It follows the same rules as [time.AddDate].

    Parameters

    • years: number
    • months: number
    • days: number

    Returns types.DateTime

  • After reports whether the current DateTime instance is after u.

    Parameters

    Returns boolean

  • Before reports whether the current DateTime instance is before u.

    Parameters

    Returns boolean

  • Compare compares the current DateTime instance with u. If the current instance is before u, it returns -1. If the current instance is after u, it returns +1. If they're the same, it returns 0.

    Parameters

    Returns number

  • Equal reports whether the current DateTime and u represent the same time instant. Two DateTime can be equal even if they are in different locations. For example, 6:00 +0200 and 4:00 UTC are Equal.

    Parameters

    Returns boolean

  • IsZero checks whether the current DateTime instance has zero time value.

    Returns boolean

  • MarshalJSON implements the [json.Marshaler] interface.

    Returns string | number[]

  • Scan implements [sql.Scanner] interface to scan the provided value into the current DateTime instance.

    Parameters

    • value: any

    Returns void

  • String serializes the current DateTime instance into a formatted UTC date string.

    The zero value is serialized to an empty string.

    Returns string

  • Sub returns a [time.Duration] by subtracting the specified DateTime from the current one.

    If the result exceeds the maximum (or minimum) value that can be stored in a [time.Duration], the maximum (or minimum) duration will be returned.

    Parameters

    Returns Duration

  • Unix returns the current DateTime as a Unix time, aka. the number of seconds elapsed since January 1, 1970 UTC.

    Returns number

  • UnmarshalJSON implements the [json.Unmarshaler] interface.

    Parameters

    • b: string | number[]

    Returns void

  • Value implements the [driver.Valuer] interface.

    Returns any

Generated using TypeDoc