tai64

package module
v0.0.0-...-c9e9c07 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 26, 2022 License: MPL-2.0 Imports: 3 Imported by: 14

README

TAI64

A TAI64 package for Go.

Package tai64 provides types for implementing the TAI64, TAI64N, and TAI64NA standards as described here https://cr.yp.to/libtai/tai64.html

The Marshal methods provide the "external" format described in the spec, which is suitable for storage or transmission over the network.

Documentation

Index

Constants

View Source
const (
	TAI64Size   = 8
	TAI64NSize  = 12
	TAI64NASize = 16
)
View Source
const UnixEpoch = TAI64(tai64Offset + 10)

UnixEpoch as TAI64

Variables

This section is empty.

Functions

func TAIFromUTC

func TAIFromUTC(unixSeconds int64) int64

TAIFromUTC applies leap seconds to seconds and returns the corresponding TAI time. unixSeconds is the number of seconds since the UNIX epoch The result IS NOT a TAI64

func UTCFromTAI

func UTCFromTAI(unixSeconds int64) int64

UTCFromTAI removes leap seconds and returns the corresponding UTC time unixSeconds is the number of seconds since the UNIX epoch

Types

type TAI64

type TAI64 uint64

func Parse

func Parse(x []byte) (TAI64, error)

func (TAI64) After

func (t TAI64) After(u TAI64) bool

func (TAI64) Before

func (t TAI64) Before(u TAI64) bool

func (TAI64) GoTime

func (t TAI64) GoTime() time.Time

GoTime returns a time.Time representing UTC time.

func (TAI64) Marshal

func (t TAI64) Marshal() []byte

func (TAI64) Marshal8

func (t TAI64) Marshal8() (ret [8]byte)

func (TAI64) MarshalBinary

func (t TAI64) MarshalBinary() ([]byte, error)

func (TAI64) String

func (t TAI64) String() string

func (TAI64) TAI64N

func (t TAI64) TAI64N() TAI64N

func (TAI64) TAI64NA

func (t TAI64) TAI64NA() TAI64NA

func (*TAI64) UnmarshalBinary

func (t *TAI64) UnmarshalBinary(data []byte) error

type TAI64N

type TAI64N struct {
	Seconds     uint64 `json:"s"`
	Nanoseconds uint32 `json:"ns"`
}

func FromGoTime

func FromGoTime(x time.Time) TAI64N

FromGoTime returns a TAI64N from a time.Time The time will be converted to UTC and then into TAI, and then finally into a TAI64N

func Now

func Now() TAI64N

Now is equivalent to FromGoTime(time.Now())

func ParseN

func ParseN(data []byte) (TAI64N, error)

func (TAI64N) After

func (t TAI64N) After(u TAI64N) bool

func (TAI64N) Before

func (t TAI64N) Before(u TAI64N) bool

func (TAI64N) GoTime

func (t TAI64N) GoTime() time.Time

GoTime returns a time.Time representing UTC time.

func (TAI64N) Marshal

func (t TAI64N) Marshal() []byte

func (TAI64N) Marshal12

func (t TAI64N) Marshal12() (ret [12]byte)

func (TAI64N) MarshalBinary

func (t TAI64N) MarshalBinary() ([]byte, error)

func (TAI64N) String

func (t TAI64N) String() string

func (TAI64N) TAI64

func (t TAI64N) TAI64() TAI64

TAI64 returns a TAI64, truncating the nanoseconds.

func (TAI64N) TAI64NA

func (t TAI64N) TAI64NA() TAI64NA

func (*TAI64N) UnmarshalBinary

func (t *TAI64N) UnmarshalBinary(data []byte) error

type TAI64NA

type TAI64NA struct {
	Seconds     uint64 `json:"s"`
	Nanoseconds uint32 `json:"ns"`
	Attoseconds uint32 `json:"as"`
}

func ParseNA

func ParseNA(data []byte) (TAI64NA, error)

func (TAI64NA) After

func (t TAI64NA) After(u TAI64NA) bool

func (TAI64NA) Before

func (t TAI64NA) Before(u TAI64NA) bool

func (TAI64NA) Marshal

func (t TAI64NA) Marshal() []byte

func (TAI64NA) Marshal16

func (t TAI64NA) Marshal16() (ret [16]byte)

func (TAI64NA) MarshalBinary

func (t TAI64NA) MarshalBinary() ([]byte, error)

func (TAI64NA) String

func (t TAI64NA) String() string

func (TAI64NA) TAI64N

func (t TAI64NA) TAI64N() TAI64N

TAI64N returns a TAI64N, truncating the attoseconds.

func (*TAI64NA) UnmarshalBinary

func (t *TAI64NA) UnmarshalBinary(data []byte) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL