timefmt

package
v0.0.0-...-ae58740 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2021 License: MPL-2.0 Imports: 6 Imported by: 2

Documentation

Overview

Package timefmt provides types for representing time formats in JSON.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Append

func Append(b []byte, t time.Time, unit Unit, epoch Epoch) []byte

func Format

func Format(t time.Time, unit Unit, epoch Epoch) string

func FormatBytes

func FormatBytes(t time.Time, unit Unit, epoch Epoch) []byte

func FromInt

func FromInt(n, nsec int64, unit Unit, epoch Epoch) time.Time

func Parse

func Parse(s string, unit Unit, epoch Epoch) (time.Time, error)

func ToInt

func ToInt(t time.Time, unit Unit, epoch Epoch) (n, nsec int64)

Types

type Chrome

type Chrome = WindowsMicro

Chrome is a time that is formatted in json as an integer representing an internal Chrome time in microseconds since 1601-01-01 00:00:00 UTC.

type Epoch

type Epoch uint8
const (
	Unix    Epoch = iota // 1970-01-01 00:00:00 UTC
	Windows              // 1601-01-01 00:00:00 UTC
)

func (Epoch) String

func (e Epoch) String() string

type QuotedChrome

type QuotedChrome struct{ time.Time }

QuotedChrome is a time that is formatted in json as a quoted integer representing an internal Chrome time in microseconds since 1601-01-01 00:00:00 UTC.

func (QuotedChrome) MarshalJSON

func (t QuotedChrome) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (QuotedChrome) MarshalText

func (t QuotedChrome) MarshalText() ([]byte, error)

MarshalText implements the text.Marshaler interface.

func (*QuotedChrome) UnmarshalJSON

func (t *QuotedChrome) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

func (*QuotedChrome) UnmarshalText

func (t *QuotedChrome) UnmarshalText(data []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

type Unit

type Unit uint8
const (
	Sec   Unit = 0
	Milli Unit = 3
	Micro Unit = 6
	Nano  Unit = 9
)

func (Unit) String

func (u Unit) String() string

type UnixMicro

type UnixMicro struct{ time.Time }

UnixMicro is a time that is formatted as an integer representing a Unix time in microseconds since 1970-01-01 00:00:00 UTC.

func (UnixMicro) Epoch

func (t UnixMicro) Epoch() Epoch

Epoch returns the epoch that times are relative to. Always Unix.

func (UnixMicro) MarshalJSON

func (t UnixMicro) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (UnixMicro) MarshalText

func (t UnixMicro) MarshalText() ([]byte, error)

MarshalText implements the text.Marshaler interface.

func (UnixMicro) Unit

func (t UnixMicro) Unit() Unit

Unit returns the unit that times are measured in. Always Micro.

func (*UnixMicro) UnmarshalJSON

func (t *UnixMicro) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

func (*UnixMicro) UnmarshalText

func (t *UnixMicro) UnmarshalText(data []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

type UnixMilli

type UnixMilli struct{ time.Time }

UnixMilli is a time that is formatted as an integer representing a Unix time in milliseconds since 1970-01-01 00:00:00 UTC.

func (UnixMilli) Epoch

func (t UnixMilli) Epoch() Epoch

Epoch returns the epoch that times are relative to. Always Unix.

func (UnixMilli) MarshalJSON

func (t UnixMilli) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (UnixMilli) MarshalText

func (t UnixMilli) MarshalText() ([]byte, error)

MarshalText implements the text.Marshaler interface.

func (UnixMilli) Unit

func (t UnixMilli) Unit() Unit

Unit returns the unit that times are measured in. Always Milli.

func (*UnixMilli) UnmarshalJSON

func (t *UnixMilli) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

func (*UnixMilli) UnmarshalText

func (t *UnixMilli) UnmarshalText(data []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

type UnixNano

type UnixNano struct{ time.Time }

UnixNano is a time that is formatted as an integer representing a Unix time in nanoseconds since 1970-01-01 00:00:00 UTC.

func (UnixNano) Epoch

func (t UnixNano) Epoch() Epoch

Epoch returns the epoch that times are relative to. Always Unix.

func (UnixNano) MarshalJSON

func (t UnixNano) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (UnixNano) MarshalText

func (t UnixNano) MarshalText() ([]byte, error)

MarshalText implements the text.Marshaler interface.

func (UnixNano) Unit

func (t UnixNano) Unit() Unit

Unit returns the unit that times are measured in. Always Nano.

func (*UnixNano) UnmarshalJSON

func (t *UnixNano) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

func (*UnixNano) UnmarshalText

func (t *UnixNano) UnmarshalText(data []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

type UnixSec

type UnixSec struct{ time.Time }

UnixSec is a time that is formatted as an integer representing a Unix time in seconds since 1970-01-01 00:00:00 UTC.

func (UnixSec) Epoch

func (t UnixSec) Epoch() Epoch

Epoch returns the epoch that times are relative to. Always Unix.

func (UnixSec) MarshalJSON

func (t UnixSec) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (UnixSec) MarshalText

func (t UnixSec) MarshalText() ([]byte, error)

MarshalText implements the text.Marshaler interface.

func (UnixSec) Unit

func (t UnixSec) Unit() Unit

Unit returns the unit that times are measured in. Always Sec.

func (*UnixSec) UnmarshalJSON

func (t *UnixSec) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

func (*UnixSec) UnmarshalText

func (t *UnixSec) UnmarshalText(data []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

type WindowsMicro

type WindowsMicro struct{ time.Time }

WindowsMicro is a time that is formatted as an integer representing a Windows time in microseconds since 1601-01-01 00:00:00 UTC.

func (WindowsMicro) Epoch

func (t WindowsMicro) Epoch() Epoch

Epoch returns the epoch that times are relative to. Always Windows.

func (WindowsMicro) MarshalJSON

func (t WindowsMicro) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (WindowsMicro) MarshalText

func (t WindowsMicro) MarshalText() ([]byte, error)

MarshalText implements the text.Marshaler interface.

func (WindowsMicro) Unit

func (t WindowsMicro) Unit() Unit

Unit returns the unit that times are measured in. Always Micro.

func (*WindowsMicro) UnmarshalJSON

func (t *WindowsMicro) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

func (*WindowsMicro) UnmarshalText

func (t *WindowsMicro) UnmarshalText(data []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

type WindowsMilli

type WindowsMilli struct{ time.Time }

WindowsMilli is a time that is formatted as an integer representing a Windows time in milliseconds since 1601-01-01 00:00:00 UTC.

func (WindowsMilli) Epoch

func (t WindowsMilli) Epoch() Epoch

Epoch returns the epoch that times are relative to. Always Windows.

func (WindowsMilli) MarshalJSON

func (t WindowsMilli) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (WindowsMilli) MarshalText

func (t WindowsMilli) MarshalText() ([]byte, error)

MarshalText implements the text.Marshaler interface.

func (WindowsMilli) Unit

func (t WindowsMilli) Unit() Unit

Unit returns the unit that times are measured in. Always Milli.

func (*WindowsMilli) UnmarshalJSON

func (t *WindowsMilli) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

func (*WindowsMilli) UnmarshalText

func (t *WindowsMilli) UnmarshalText(data []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

type WindowsNano

type WindowsNano struct{ time.Time }

WindowsNano is a time that is formatted as an integer representing a Windows time in nanoseconds since 1601-01-01 00:00:00 UTC.

func (WindowsNano) Epoch

func (t WindowsNano) Epoch() Epoch

Epoch returns the epoch that times are relative to. Always Windows.

func (WindowsNano) MarshalJSON

func (t WindowsNano) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (WindowsNano) MarshalText

func (t WindowsNano) MarshalText() ([]byte, error)

MarshalText implements the text.Marshaler interface.

func (WindowsNano) Unit

func (t WindowsNano) Unit() Unit

Unit returns the unit that times are measured in. Always Nano.

func (*WindowsNano) UnmarshalJSON

func (t *WindowsNano) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

func (*WindowsNano) UnmarshalText

func (t *WindowsNano) UnmarshalText(data []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

type WindowsSec

type WindowsSec struct{ time.Time }

WindowsSec is a time that is formatted as an integer representing a Windows time in seconds since 1601-01-01 00:00:00 UTC.

func (WindowsSec) Epoch

func (t WindowsSec) Epoch() Epoch

Epoch returns the epoch that times are relative to. Always Windows.

func (WindowsSec) MarshalJSON

func (t WindowsSec) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (WindowsSec) MarshalText

func (t WindowsSec) MarshalText() ([]byte, error)

MarshalText implements the text.Marshaler interface.

func (WindowsSec) Unit

func (t WindowsSec) Unit() Unit

Unit returns the unit that times are measured in. Always Sec.

func (*WindowsSec) UnmarshalJSON

func (t *WindowsSec) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

func (*WindowsSec) UnmarshalText

func (t *WindowsSec) UnmarshalText(data []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

Jump to

Keyboard shortcuts

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