when

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2022 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TimeFormats = []string{
	"2006", "2006-1", "2006-1-2", "2006-1-2 15", "2006-1-2 15:4", "2006-1-2 15:4:5", "1-2",
	"15:4:5", "15:4", "15",
	"15:4:5 Jan 2, 2006 MST", "2006-01-02 15:04:05.999999999 -0700 MST", "2006-01-02T15:04:05Z0700", "2006-01-02T15:04:05Z07",
	"2006.1.2", "2006.1.2 15:04:05", "2006.01.02", "2006.01.02 15:04:05", "2006.01.02 15:04:05.999999999",
	"1/2/2006", "1/2/2006 15:4:5", "2006/01/02", "20060102", "2006/01/02 15:04:05",
	time.ANSIC, time.UnixDate, time.RubyDate, time.RFC822, time.RFC822Z, time.RFC850,
	time.RFC1123, time.RFC1123Z, time.RFC3339, time.RFC3339Nano,
	time.Kitchen, time.Stamp, time.StampMilli, time.StampMicro, time.StampNano,
}

TimeFormats default time formats will be parsed as

View Source
var WeekStartDay = time.Sunday

WeekStartDay set week start day, default is sunday

Functions

func BeginningOfDay

func BeginningOfDay() time.Time

BeginningOfDay beginning of day

func BeginningOfHour

func BeginningOfHour() time.Time

BeginningOfHour beginning of hour

func BeginningOfMinute

func BeginningOfMinute() time.Time

BeginningOfMinute beginning of minute

func BeginningOfMonth

func BeginningOfMonth() time.Time

BeginningOfMonth beginning of month

func BeginningOfQuarter

func BeginningOfQuarter() time.Time

BeginningOfQuarter beginning of quarter

func BeginningOfWeek

func BeginningOfWeek() time.Time

BeginningOfWeek beginning of week

func BeginningOfYear

func BeginningOfYear() time.Time

BeginningOfYear beginning of year

func Between

func Between(time1, time2 string) bool

Between check now between the begin, end time or not

func EndOfDay

func EndOfDay() time.Time

EndOfDay end of day

func EndOfHour

func EndOfHour() time.Time

EndOfHour end of hour

func EndOfMinute

func EndOfMinute() time.Time

EndOfMinute end of minute

func EndOfMonth

func EndOfMonth() time.Time

EndOfMonth end of month

func EndOfQuarter

func EndOfQuarter() time.Time

EndOfQuarter end of quarter

func EndOfSunday

func EndOfSunday() time.Time

EndOfSunday end of sunday

func EndOfWeek

func EndOfWeek() time.Time

EndOfWeek end of week

func EndOfYear

func EndOfYear() time.Time

EndOfYear end of year

func Monday

func Monday(strs ...string) time.Time

func MustParse

func MustParse(strs ...string) time.Time

MustParse must parse string to time or will panic

func MustParseInLocation

func MustParseInLocation(loc *time.Location, strs ...string) time.Time

MustParseInLocation must parse string to time in location or will panic

func Parse

func Parse(strs ...string) (time.Time, error)

Parse parse string to time

func ParseInLocation

func ParseInLocation(loc *time.Location, strs ...string) (time.Time, error)

ParseInLocation parse string to time in location

func Quarter

func Quarter() uint

Quarter returns the yearly quarter

func Sunday

func Sunday(strs ...string) time.Time

Sunday sunday

Types

type Config

type Config struct {
	WeekStartDay time.Weekday
	TimeLocation *time.Location
	TimeFormats  []string
}

Config configuration for now package

var DefaultConfig *Config

DefaultConfig default config

func (*Config) MustParse

func (config *Config) MustParse(strs ...string) time.Time

MustParse must parse string to time or will panic

func (*Config) Parse

func (config *Config) Parse(strs ...string) (time.Time, error)

Parse parse string to time based on configuration

func (*Config) With

func (config *Config) With(t time.Time) *When

New initialize When based on configuration

type When

type When struct {
	time.Time
	*Config
}

Now now struct

func New

func New(t time.Time) *When

New initialize When with time

func With

func With(t time.Time) *When

With initialize Now with time

func (*When) BeginningOfDay

func (now *When) BeginningOfDay() time.Time

BeginningOfDay beginning of day

func (*When) BeginningOfHalf

func (now *When) BeginningOfHalf() time.Time

BeginningOfHalf beginning of half year

func (*When) BeginningOfHour

func (now *When) BeginningOfHour() time.Time

BeginningOfHour beginning of hour

func (*When) BeginningOfMinute

func (now *When) BeginningOfMinute() time.Time

BeginningOfMinute beginning of minute

func (*When) BeginningOfMonth

func (now *When) BeginningOfMonth() time.Time

BeginningOfMonth beginning of month

func (*When) BeginningOfQuarter

func (now *When) BeginningOfQuarter() time.Time

BeginningOfQuarter beginning of quarter

func (*When) BeginningOfWeek

func (now *When) BeginningOfWeek() time.Time

BeginningOfWeek beginning of week

func (*When) BeginningOfYear

func (now *When) BeginningOfYear() time.Time

BeginningOfYear BeginningOfYear beginning of year

func (*When) Between

func (now *When) Between(begin, end string) bool

Between check time between the begin, end time or not

func (*When) EndOfDay

func (now *When) EndOfDay() time.Time

EndOfDay end of day

func (*When) EndOfHalf

func (now *When) EndOfHalf() time.Time

EndOfHalf end of half year

func (*When) EndOfHour

func (now *When) EndOfHour() time.Time

EndOfHour end of hour

func (*When) EndOfMinute

func (now *When) EndOfMinute() time.Time

EndOfMinute end of minute

func (*When) EndOfMonth

func (now *When) EndOfMonth() time.Time

EndOfMonth end of month

func (*When) EndOfQuarter

func (now *When) EndOfQuarter() time.Time

EndOfQuarter end of quarter

func (*When) EndOfSunday

func (now *When) EndOfSunday() time.Time

EndOfSunday end of sunday

func (*When) EndOfWeek

func (now *When) EndOfWeek() time.Time

EndOfWeek end of week

func (*When) EndOfYear

func (now *When) EndOfYear() time.Time

EndOfYear end of year

func (*When) Monday

func (now *When) Monday(strs ...string) time.Time

func (*When) MustParse

func (now *When) MustParse(strs ...string) (t time.Time)

MustParse must parse string to time or it will panic

func (*When) Parse

func (now *When) Parse(strs ...string) (t time.Time, err error)

Parse parse string to time

func (*When) Quarter

func (now *When) Quarter() uint

Quarter returns the yearly quarter

func (*When) Sunday

func (now *When) Sunday(strs ...string) time.Time

Jump to

Keyboard shortcuts

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