timestamp

package
v1.0.75 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2026 License: MIT Imports: 2 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DisplayFormat string = "02/01/2006, 15:04:05"
)

Variables

This section is empty.

Functions

func Format

func Format[T Timestamp](ts T, format string) string

Format formats a timestamp as a string using the given format in UTC

func FormatLocal

func FormatLocal[T Timestamp](ts T, format string) string

FormatLocal formats a timestamp as a string using the given format in local time

Types

type Micro

type Micro int64 // // type representing a timestamp in microseconds

func ConvertToMicro

func ConvertToMicro[T Timestamp](from T) Micro

ConvertToMicro converts any Timestamp to Micro

func NowMicro

func NowMicro() Micro

NowMicro returns the current time as Micro

func (Micro) ToNanos

func (m Micro) ToNanos() Nano

ToNanos converts Micro to nanoseconds

func (Micro) ToTime

func (m Micro) ToTime() time.Time

ToTime converts Micro timestamp to time.Time

type Milli

type Milli int64 // type representing a timestamp in milliseconds

func ConvertToMilli

func ConvertToMilli[T Timestamp](from T) Milli

ConvertToMilli converts any Timestamp to Milli

func NowMilli

func NowMilli() Milli

NowMilli returns the current time as Milli

func (Milli) ToNanos

func (m Milli) ToNanos() Nano

ToNanos converts Milli to nanoseconds

func (Milli) ToTime

func (m Milli) ToTime() time.Time

ToTime converts Milli timestamp to time.Time

type Nano

type Nano int64 // // type representing a timestamp in nanoseconds

func ConvertToNano

func ConvertToNano[T Timestamp](from T) Nano

ConvertToNano converts any Timestamp to Nano

func NowNano

func NowNano() Nano

NowNano returns the current time as Nano

func Parse

func Parse(format, date string) Nano

Parse parses a date string using the given format and returns a timestamp of the specified type

func ParseErr

func ParseErr(format, date string) (Nano, error)

ParseErr parses a date string using the given format and returns a timestamp of the specified type

func ParseF

func ParseF(format, date string, fields ...any) Nano

ParseF parses a date string using the given format and returns a timestamp of the specified type (attaches fields to log)

func ParseM

func ParseM(format, date string, fields map[string]any) Nano

ParseM parses a date string using the given format and returns a timestamp of the specified type (attaches fields to log)

func (Nano) ToNanos

func (n Nano) ToNanos() Nano

ToNanos converts Nano to nanoseconds

func (Nano) ToTime

func (n Nano) ToTime() time.Time

ToTime converts Nano timestamp to time.Time

type Seconds

type Seconds int64 // type representing a timestamp in seconds

func ConvertToSeconds

func ConvertToSeconds[T Timestamp](from T) Seconds

ConvertToSeconds converts any Timestamp to Seconds

func NowSeconds

func NowSeconds() Seconds

NowSeconds returns the current time as Seconds

func (Seconds) ToNanos

func (s Seconds) ToNanos() Nano

ToNanos converts Seconds to nanoseconds

func (Seconds) ToTime

func (s Seconds) ToTime() time.Time

ToTime converts Seconds timestamp to time.Time

type Timestamp

type Timestamp interface {
	~int64
	ToTime() time.Time
	ToNanos() Nano
}

Jump to

Keyboard shortcuts

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