Documentation
¶
Index ¶
- Constants
- func Encode(time *Time, dst []byte) (bytesEncoded int, isComplete bool, err error)
- func EncodedSize(time *Time) int
- type Time
- func AsCompactTime(src *gotime.Time) (result *Time)
- func DecodeDate(src []byte) (time *Time, bytesDecoded int, isComplete bool, err error)
- func DecodeTime(src []byte) (time *Time, bytesDecoded int, isComplete bool, err error)
- func DecodeTimestamp(src []byte) (time *Time, bytesDecoded int, isComplete bool, err error)
- func NewDate(year, month, day int) *Time
- func NewTime(hour, minute, second, nanosecond int, areaLocation string) *Time
- func NewTimeLatLong(hour, minute, second, nanosecond, latitudeHundredths, longitudeHundredths int) *Time
- func NewTimestamp(year, month, day, hour, minute, second, nanosecond int, areaLocation string) *Time
- func NewTimestampLatLong(...) *Time
- func (this *Time) AsGoTime() (result *gotime.Time, err error)
- func (this *Time) InitDate(year, month, day int)
- func (this *Time) InitTime(hour, minute, second, nanosecond int, areaLocation string)
- func (this *Time) InitTimeLatLong(hour, minute, second, nanosecond, latitudeHundredths, longitudeHundredths int)
- func (this *Time) InitTimestamp(year, month, day, hour, minute, second, nanosecond int, areaLocation string)
- func (this *Time) InitTimestampLatLong(...)
- func (this *Time) Validate() (err error)
- type TimeType
- type TimezoneType
Constants ¶
const ( TypeDate = TimeType(iota) TypeTime TypeTimestamp )
const ( TypeUTC = TimezoneType(iota) TypeAreaLocation TypeLatitudeLongitude )
Variables ¶
This section is empty.
Functions ¶
func Encode ¶ added in v1.0.1
Encode a time value (date, time, or timestamp). Returns the number of bytes encoded, or the number of bytes it attempted to encode. Returns isComplete=true if there was enough room in dst. Returns an error if something went wrong other than there not being enough room.
func EncodedSize ¶ added in v1.0.1
Get the number of bytes that would be required to encode this time value.
Types ¶
type Time ¶ added in v1.0.1
type Time struct {
Year int
Nanosecond int32
LatitudeHundredths int16
LongitudeHundredths int16
Month int8
Day int8
Hour int8
Minute int8
Second int8
TimeIs TimeType
TimezoneIs TimezoneType
AreaLocation string
}
func AsCompactTime ¶ added in v1.0.1
func DecodeDate ¶
Decode a date. Returns the number of bytes decoded, or the number of bytes it attempted to decode. Returns isComplete=true if there was enough data in src. If isComplete == false, the resulting date is invalid.
func DecodeTime ¶
Decode a time value. Returns the number of bytes decoded, or the number of bytes it attempted to decode. Returns isComplete=true if there was enough data in src. If isComplete == false or err != nil, the resulting time value is invalid.
func DecodeTimestamp ¶
Decode a timestamp. Returns the number of bytes decoded, or the number of bytes it attempted to decode. Returns isComplete=true if there was enough data in src. If isComplete == false or err != nil, the resulting timestamp is invalid.
func NewTimeLatLong ¶ added in v1.0.1
func NewTimestamp ¶ added in v1.0.1
func NewTimestamp(year, month, day, hour, minute, second, nanosecond int, areaLocation string) *Time
Create a new timestamp. If areaLocation is empty, UTC is assumed.
func NewTimestampLatLong ¶ added in v1.0.1
func (*Time) AsGoTime ¶ added in v1.0.1
Convert this time into a standard go time. Note: Go time doesn't support latitude/longitude time zones. Attempting to
convert this type of time zone will result in an error.
func (*Time) InitTimeLatLong ¶ added in v1.0.1
func (*Time) InitTimestamp ¶ added in v1.0.1
func (this *Time) InitTimestamp(year, month, day, hour, minute, second, nanosecond int, areaLocation string)
Init a timestamp. If areaLocation is empty, UTC is assumed.
func (*Time) InitTimestampLatLong ¶ added in v1.0.1
func (*Time) Validate ¶ added in v1.0.1
Validate this time. Only basic validation is performed, enough to ensure that it isn't blatantly wrong (such as invalid area/location values, latitude 500, december 54th, etc). It does not do more nuanced checks such as on which years February 29th is valid, or when leap seconds are allowed. It also doesn't check for impossible timestamp values such as 2011-03-13/02:10:00/Los_Angeles.
Note: The field AreaLocation is not validated. You can validate this field using time.LoadLocation() or time.LoadLocationFromTZData().
type TimezoneType ¶ added in v1.0.1
type TimezoneType int8