unixtimestamp

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

unixtimestamp package provides a time.Time wrapper that marshals to/from Unix timestamp (integer, seconds)

Index

Constants

This section is empty.

Variables

Endian is the default byte order for UnixTimestamp for MarshalBinary interface

View Source
var Errorf = fmt.Errorf
View Source
var FuncFrom = FSeconds // Change FuncTo also. consider FMilli.
View Source
var FuncTo = TSeconds // consider TMilli
View Source
var NoCheckTimeScan bool

Functions

func FMicro added in v0.0.5

func FMicro(t time.Time) int64

func FMilli added in v0.0.5

func FMilli(t time.Time) int64

func FSeconds added in v0.0.5

func FSeconds(t time.Time) int64

func TMicro added in v0.0.5

func TMicro(i int64) time.Time

func TMilli added in v0.0.5

func TMilli(i int64) time.Time

func TSeconds added in v0.0.5

func TSeconds(i int64) time.Time

Types

type UnixTimestamp

type UnixTimestamp = UnixTimestampNull

UnixTimestamp is a time.Time that marshals to/from Unix timestamp (seconds) Use pointer (*UnixTimestamp) and `omitempty` in structs for JSON marshaling Use Wrap(t) or Now() to create a UnixTimestamp

func New

func New(t time.Time) *UnixTimestamp

New existing time.Time

func Now

func Now() *UnixTimestamp

Now returns a new UnixTimestamp for the current time

func (UnixTimestamp) MarshalBinary

func (ut UnixTimestamp) MarshalBinary() ([]byte, error)

MarshalBinary uses Endian var, set Endian to binary.BigEndian if needed

func (UnixTimestamp) MarshalJSON

func (ut UnixTimestamp) MarshalJSON() ([]byte, error)

func (*UnixTimestamp) Scan added in v0.0.5

func (u *UnixTimestamp) Scan(v interface{}) error

func (*UnixTimestamp) UnmarshalBinary

func (ut *UnixTimestamp) UnmarshalBinary(dat []byte) error

UnmarshalBinary uses Endian var, set Endian to binary.BigEndian if needed

func (*UnixTimestamp) UnmarshalJSON

func (ut *UnixTimestamp) UnmarshalJSON(dat []byte) error

type UnixTimestampNotNull added in v0.0.6

type UnixTimestampNotNull struct {
	UnixTimestamp
}

func (*UnixTimestampNotNull) Value added in v0.0.6

func (u *UnixTimestampNotNull) Value() (driver.Value, error)

type UnixTimestampNull added in v0.0.6

type UnixTimestampNull struct {
	time.Time
}

func (UnixTimestampNull) Value added in v0.0.6

func (u UnixTimestampNull) Value() (driver.Value, error)

Value is returns nil if zero time. Wrap with UnixTimestampNotNull for not null

Jump to

Keyboard shortcuts

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