format

package
v0.11.51 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2025 License: MIT Imports: 3 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultTimePrintFormat is the default time format: UTC, Local, Ago
	DefaultTimePrintFormat = "UTC"

	// DefaultTimeFormatZone is the default time format
	DefaultTimeFormatZone = "2006-01-02T15:04:05.999+07:00"
	// DefaultTimeFormatUTC is the default time format
	DefaultTimeFormatUTC = "2006-01-02T15:04:05.999Z"

	// DefaultTimeTruncate is the default time to truncate as Postgres time precision is default to 6
	// However, JavaScript and AWS accept time milliseconds only, 3 digits, so we truncate to 3
	DefaultTimeTruncate = time.Millisecond

	NowFunc = time.Now
)

Functions

func Enabled

func Enabled(val bool) string

func Float

func Float[T ~float32 | ~float64](val T) string

func LocalTime

func LocalTime(val any) string

LocalTime returns local time

func Number

func Number[T ~int | ~int32 | ~uint | ~uint32 | ~int64 | ~uint64](val T) string

func ParseStringTime

func ParseStringTime(val string) time.Time

ParseStringTime returns Time from a string

func ParseTime

func ParseTime(val any) time.Time

ParseTime returns time from any type

func Time

func Time(val any) string

Time returns formatted time

func TimeAgo

func TimeAgo(val any) string

TimeAgo returns elapsed time since

func TimesElapsed

func TimesElapsed(from, to any) (created string, updated string, elapsed string)

TimesElapsed returns formatted times and elapsed time

func YesNo

func YesNo(val bool) string

Types

This section is empty.

Jump to

Keyboard shortcuts

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