Documentation
¶
Overview ¶
Package compact_time provides encoding and decoding mechanisms for the compact time format (https://github.com/kstenerud/compact-time), as well as basic conversion functions to/from the go time package.
Basic validation is performed when decoding data, enough to ensure that it isn't blatantly wrong (such as invalid area/location values, latitude 500, december 54th, etc). However, 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.
Package compact_time provides encoding and decoding mechanisms for the compact time format (https://github.com/kstenerud/compact-time), as well as basic conversion functions to/from the go time package.
Basic validation is performed when decoding data, enough to ensure that it isn't blatantly wrong (such as invalid area/location values, latitude 500, december 54th, etc). However, 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.
Package compact_time provides encoding and decoding mechanisms for the compact time format (https://github.com/kstenerud/compact-time), as well as basic conversion functions to/from the go time package.
Basic validation is performed when decoding data, enough to ensure that it isn't blatantly wrong (such as invalid area/location values, latitude 500, december 54th, etc). However, 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.
Index ¶
- Constants
- Variables
- func DecodeGoDate(reader io.Reader) (time gotime.Time, bytesDecoded int, err error)
- func DecodeGoDateWithBuffer(reader io.Reader, buffer []byte) (time gotime.Time, bytesDecoded int, err error)
- func DecodeGoTime(reader io.Reader) (time gotime.Time, bytesDecoded int, err error)
- func DecodeGoTimeWithBuffer(reader io.Reader, buffer []byte) (time gotime.Time, bytesDecoded int, err error)
- func DecodeGoTimestamp(reader io.Reader) (time gotime.Time, bytesDecoded int, err error)
- func DecodeGoTimestampWithBuffer(reader io.Reader, buffer []byte) (time gotime.Time, bytesDecoded int, err error)
- func EncodeGoDate(time gotime.Time, writer io.Writer) (bytesEncoded int, err error)
- func EncodeGoDateToBytes(time gotime.Time, buffer []byte) (bytesEncoded int)
- func EncodeGoTime(time gotime.Time, writer io.Writer) (bytesEncoded int, err error)
- func EncodeGoTimeToBytes(time gotime.Time, buffer []byte) (bytesEncoded int)
- func EncodeGoTimestamp(time gotime.Time, writer io.Writer) (bytesEncoded int, err error)
- func EncodeGoTimestampToBytes(time gotime.Time, buffer []byte) (bytesEncoded int)
- func EncodedSizeGoDate(time gotime.Time) int
- func EncodedSizeGoTime(time gotime.Time) int
- func EncodedSizeGoTimestamp(time gotime.Time) int
- type Time
- func AsCompactTime(src gotime.Time) (Time, error)
- func DecodeDate(reader io.Reader) (time Time, bytesDecoded int, err error)
- func DecodeDateWithBuffer(reader io.Reader, buffer []byte) (time Time, bytesDecoded int, err error)
- func DecodeTime(reader io.Reader) (time Time, bytesDecoded int, err error)
- func DecodeTimeWithBuffer(reader io.Reader, buffer []byte) (time Time, bytesDecoded int, err error)
- func DecodeTimestamp(reader io.Reader) (time Time, bytesDecoded int, err error)
- func DecodeTimestampWithBuffer(reader io.Reader, buffer []byte) (time Time, bytesDecoded int, err error)
- func NewDate(year, month, day int) (Time, error)
- func NewTime(hour, minute, second, nanosecond int, areaLocation string) (Time, error)
- func NewTimeLatLong(hour, minute, second, nanosecond, latitudeHundredths, longitudeHundredths int) (Time, error)
- func NewTimestamp(year, month, day, hour, minute, second, nanosecond int, areaLocation string) (Time, error)
- func NewTimestampLatLong(...) (Time, error)
- func ZeroDate() Time
- func ZeroTime() Time
- func ZeroTimestamp() Time
- func (this *Time) AsGoTime() (result gotime.Time, err error)
- func (this *Time) Encode(writer io.Writer) (bytesEncoded int, err error)
- func (this *Time) EncodeToBytes(buffer []byte) (bytesEncoded int)
- func (this *Time) EncodedSize() int
- func (this *Time) InitDate(year, month, day int) error
- func (this *Time) InitTime(hour, minute, second, nanosecond int, areaLocation string) error
- func (this *Time) InitTimeLatLong(hour, minute, second, nanosecond, latitudeHundredths, longitudeHundredths int) error
- func (this *Time) InitTimestamp(year, month, day, hour, minute, second, nanosecond int, areaLocation string) error
- func (this *Time) InitTimestampLatLong(...) error
- func (this *Time) IsZeroValue() bool
- func (this *Time) String() string
- type TimeType
- type TimezoneType
Constants ¶
const ( TypeDate = TimeType(iota) TypeTime TypeTimestamp )
const ( TypeZeroValue = TimezoneType(iota) TypeZero TypeLocal TypeAreaLocation TypeLatitudeLongitude )
const MaxEncodeLength = 50
Maximum byte length that this library will encode
const RequiredBufferSize = 127
Variables ¶
var ErrorIncomplete = fmt.Errorf("Compact time value is incomplete")
Functions ¶
func DecodeGoDate ¶ added in v1.5.0
Decode a go date.
func DecodeGoDateWithBuffer ¶ added in v1.7.0
func DecodeGoTime ¶ added in v1.5.0
Decode a go time value.
func DecodeGoTimeWithBuffer ¶ added in v1.7.0
func DecodeGoTimestamp ¶ added in v1.5.0
Decode a go timestamp.
func DecodeGoTimestampWithBuffer ¶ added in v1.7.0
func EncodeGoDate ¶ added in v1.5.0
func EncodeGoDateToBytes ¶ added in v1.7.0
func EncodeGoTime ¶ added in v1.5.0
func EncodeGoTimeToBytes ¶ added in v1.7.0
func EncodeGoTimestamp ¶ added in v1.5.0
func EncodeGoTimestampToBytes ¶ added in v1.7.0
func EncodedSizeGoDate ¶ added in v1.5.0
func EncodedSizeGoTime ¶ added in v1.5.0
func EncodedSizeGoTimestamp ¶ added in v1.5.0
Types ¶
type Time ¶ added in v1.0.1
type Time struct {
ShortAreaLocation string
LongAreaLocation string
Year int
Nanosecond uint32
LatitudeHundredths int16
LongitudeHundredths int16
Month uint8
Day uint8
Hour uint8
Minute uint8
Second uint8
TimeType TimeType
TimezoneType TimezoneType
}
func DecodeDate ¶
Decode a date.
func DecodeDateWithBuffer ¶ added in v1.7.0
func DecodeTime ¶
Decode a time value.
func DecodeTimeWithBuffer ¶ added in v1.7.0
func DecodeTimestamp ¶
Decode a timestamp.
func DecodeTimestampWithBuffer ¶ added in v1.7.0
func NewTime ¶ added in v1.0.1
Create a new time. If areaLocation is empty, UTC is assumed. areaLocation is not validated against any timezone databases.
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, error)
Create a new timestamp. If areaLocation is empty, UTC is assumed. areaLocation is not validated against any timezone databases.
func NewTimestampLatLong ¶ added in v1.0.1
func ZeroTimestamp ¶ added in v1.6.0
func ZeroTimestamp() Time
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.
Note: Converting to go time will validate area/location time zone (if any)
func (*Time) EncodeToBytes ¶ added in v1.7.0
Encode a time value (date, time, or timestamp) to a byte array. Assumes that the buffer is big enough.
func (*Time) EncodedSize ¶ added in v1.5.0
Get the number of bytes that would be required to encode this time value.
func (*Time) InitTime ¶ added in v1.0.1
Init a time. If areaLocation is empty, UTC is assumed. areaLocation is not validated against any timezone databases.
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) error
Init a timestamp. If areaLocation is empty, UTC is assumed. areaLocation is not validated against any timezone databases.
func (*Time) InitTimestampLatLong ¶ added in v1.0.1
func (*Time) IsZeroValue ¶ added in v1.6.0
type TimezoneType ¶ added in v1.0.1
type TimezoneType uint8