tai64n

package module
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2022 License: GPL-3.0 Imports: 6 Imported by: 1

Documentation

Overview

TAI64/TAI64N (http://cr.yp.to/libtai/tai64.html) dealing library. You can convert time to TAI64/TAI64N and vice versa with it.

tai := new(tai64n.TAI64N)
tai.FromTime(time.Now())
printable := tai64n.Encode(tai[:])
decoded, err := tai64n.Decode(printable)
tai64n.ToTime(tai[:]) == decoded

By default TAI64 timestamps contain initial 1972-01-01 10-seconds TAI<->UTC difference. If you need honest TAI representation, then you should also use Leapsecs* functions.

Index

Constants

View Source
const (
	TAI64Size  = 8
	TAI64NSize = TAI64Size + 4
	LocalFmt   = "2006-01-02 15:04:05.000000000"
	Base       = 0x4000000000000000 + Leapsecs1972
)
View Source
const Leapsecs1972 = 10

Variables

View Source
var LeapsecsDB []int64

Database of Unix timestamps of the time when leap second occurred. Library contains and initializes it with leap seconds up to 2016-12-31.

Functions

func Decode

func Decode(s string) (time.Time, error)

Convert TAI64/TAI64N "@HEX(TAI64)" format to Time.

func Encode

func Encode(tai []byte) string

Convert TAI64/TAI64N to "@HEX(TAI64)" format.

func LeapsecsAdd

func LeapsecsAdd(t time.Time) time.Time

Add currently known (LeapsecsDB) leap seconds, not including initial 1972-01-01 10-seconds offset.

func LeapsecsDBLoad

func LeapsecsDBLoad(buf []byte)

Load "leapsecs.dat"-like database: concatenated TAI64 leap seconds. Function panics if encoding is invalid.

func LeapsecsDiff

func LeapsecsDiff(t int64) int

TAI<->UTC difference for the given Unix timestamp.

func LeapsecsSub

func LeapsecsSub(t time.Time) time.Time

Opposite of LeapsecsAdd().

func ToTime

func ToTime(tai []byte) time.Time

Types

type Int64s

type Int64s []int64

func (Int64s) Len

func (a Int64s) Len() int

func (Int64s) Less

func (a Int64s) Less(i, j int) bool

func (Int64s) Swap

func (a Int64s) Swap(i, j int)

type TAI64

type TAI64 [TAI64Size]byte

func (*TAI64) FromTime

func (dst *TAI64) FromTime(src time.Time)

type TAI64N

type TAI64N [TAI64NSize]byte

func (*TAI64N) FromTime

func (dst *TAI64N) FromTime(src time.Time)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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