tai64 and tai64n parsing and formatting for Go
Find a file
elij 54ba43e896
All checks were successful
unit-tests / Build (push) Successful in 1m22s
fix badge image in readme
2025-12-17 15:38:52 -08:00
.forgejo/workflows add codeberg ci 2025-12-17 15:36:38 -08:00
.github update CI env vars 2024-08-14 14:32:16 -07:00
tools refactor generator code 2024-04-17 15:12:55 -07:00
.gitignore add script with some source options, as maia.usno.navy.mil is still down 2021-09-22 13:42:49 -07:00
go.mod move to codeberg 2025-12-16 17:15:12 -08:00
LICENSE.md update license 2019-04-30 23:16:29 -07:00
offsets.go refactor generator code 2024-04-17 15:12:55 -07:00
README.md fix badge image in readme 2025-12-17 15:38:52 -08:00
time.go oops. remove debug print. 2019-03-07 00:48:19 -08:00
time_test.go some refactor for clarity 2019-03-07 00:46:05 -08:00

tai64

Build Status GoDoc Go Report Card

About

Formats and parses TAI64 and TAI64N timestamps.

Usage

package main

import (
	"fmt"
	"os"
	"time"

	"github.com/cactus/tai64"
)

func main() {
	t := time.Now()
	fmt.Println(t)

	s := tai64.FormatNano(t)
	fmt.Println(s)

	p, err := tai64.Parse(s)
	if err != nil {
		fmt.Println("Failed to decode time")
		os.Exit(1)
	}

    // tai64 times are in UTC
    fmt.Println(p)

    // time.Equal properly compares times with different locations.
	if t.Equal(p) {
		fmt.Println("equal")
	} else {
		fmt.Println("not equal")
	}
}

Output:

2016-05-25 13:44:01.281160355 -0700 PDT
@4000000057460eb510c22aa3
2016-05-25 20:44:01.281160355 +0000 UTC
equal

License

Released under the ISC license. See LICENSE.md file for details.