ztime

package
v0.12.7 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Nanosecond  Duration = Duration(time.Nanosecond)
	Microsecond          = Duration(time.Microsecond)
	Millisecond          = Duration(time.Millisecond)
	Second               = Duration(time.Second)
	Minute               = Duration(time.Minute)
	Hour                 = Duration(time.Hour)
	Day                  = Duration(time.Hour) * 24
	Week                 = Day * 7
	Month                = Day * 31
	Year                 = Day * 365
	Decade               = Year * 10
	Century              = Decade * 10
)
View Source
const (
	ISO8601 = "2006-01-02T15:04:05-0700"
)

Variables

This section is empty.

Functions

func EqualWithin added in v0.12.1

func EqualWithin(t1, t2 time.Time, within time.Duration) bool

Returns true if the two times are within the given duration of each other

func IsWeekday

func IsWeekday(date time.Time) bool

Returns true if the given date falls on a weekday

func IsWeekend

func IsWeekend(date time.Time) bool

Returns true if the given date falls on a weekend

func MustParse added in v0.10.7

func MustParse(val string, formats ...string) (t time.Time)

Parse successfully or panic

func MustParseUnix added in v0.10.7

func MustParseUnix(seconds string, nanos string) (t time.Time)

ParseUnix successfully or panic

func Parse added in v0.8.2

func Parse(val string, formats ...string) (t time.Time, err error)

Attempt to parse a time using all known formats. If formats are passed in, we attempt to parse using those formats first. An error is thrown only if no matching formats are found.

func ParseUnix added in v0.9.1

func ParseUnix(seconds string, nanos string) (t time.Time, err error)

The same as time.Unix, but the arguments are strings

Types

type Duration added in v0.7.10

type Duration time.Duration

func ParseDuration added in v0.7.9

func ParseDuration(s string) (Duration, error)

Extend version of ParseDuration. Source code is almost identical to Supports day (d) and week (w) units as well as general month (M) and year (Y) durations. Month is defined as 31 days and a year is 365 days.

func (*Duration) Set added in v0.9.5

func (d *Duration) Set(val string) (err error)

func (Duration) String added in v0.7.10

func (d Duration) String() string

func (*Duration) UnmarshalJSON added in v0.7.10

func (d *Duration) UnmarshalJSON(val []byte) (err error)

func (*Duration) UnmarshalYAML added in v0.7.10

func (d *Duration) UnmarshalYAML(unmarshal func(interface{}) error) (err error)

type ParseError added in v0.7.9

type ParseError struct {
	Layout     string
	Value      string
	LayoutElem string
	ValueElem  string
	Message    string
}

ParseError describes a problem parsing a time string.

Jump to

Keyboard shortcuts

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