tai64

package module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: ISC Imports: 3 Imported by: 2

README

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.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Format

func Format(t time.Time) string

Format formats a time.Time as a TAI64 timestamp returns a string TAI64 timestamps

func FormatNano

func FormatNano(t time.Time) string

FormatNano formats a time.Time as a TAI64N timestamp returns a string TAI64N timestamps

func GetOffsetTime

func GetOffsetTime(t time.Time) int64

GetOffsetTime returns the TAI64 offset for a time.Time in UTC returns int64 offset

func GetOffsetUnix

func GetOffsetUnix(utime int64) int64

GetOffsetUnix returns the TAI64 offset for a UTC unix timestamp returns int64 offset

func Parse

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

Parse parses a TAI64 or TAI64N timestamp returns a time.Time and an error.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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