MCPcopy Create free account
hub / github.com/cockroachdb/cockroachdb-parser / AddTimeZone

Method AddTimeZone

pkg/sql/sem/tree/datum.go:3103–3111  ·  view source on GitHub ↗

AddTimeZone uses the supplied location to convert this Timestamp to a timestamp with a timezone. It is the inverse of EvalAtAndRemoveTimeZone.

(
	loc *time.Location, precision time.Duration,
)

Source from the content-addressed store, hash-verified

3101// AddTimeZone uses the supplied location to convert this Timestamp to a
3102// timestamp with a timezone. It is the inverse of EvalAtAndRemoveTimeZone.
3103func (d *DTimestamp) AddTimeZone(
3104 loc *time.Location, precision time.Duration,
3105) (*DTimestampTZ, error) {
3106 // Treat the Timestamp as if it were already shifted by the location offset,
3107 // and shift by the negative offset to convert it to UTC.
3108 _, locOffset := d.Time.In(loc).Zone()
3109 t := d.Time.Add(time.Duration(-locOffset) * time.Second)
3110 return MakeDTimestampTZ(t.UTC(), precision)
3111}
3112
3113// DInterval is the interval Datum.
3114type DInterval struct {

Callers

nothing calls this directly

Calls 4

MakeDTimestampTZFunction · 0.85
InMethod · 0.80
DurationMethod · 0.80
AddMethod · 0.65

Tested by

no test coverage detected