Skip to content
/ tai64 Public

tai64 and tai64n parsing and formatting for Go

License

Notifications You must be signed in to change notification settings

cactus/tai64

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tai64

Build Status GoDoc Go Report Card License

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.