Documentation ¶
Index ¶
- func IsValidTime(input string) bool
- type Date
- type Duration
- func MustNewDurationFromString(input string) Duration
- func NewDuration() Duration
- func NewDurationFromHours(hours float64) Duration
- func NewDurationFromMinutes(minutes int) Duration
- func NewDurationFromString(input string) (Duration, error)
- func NewDurationFromTime(duration time.Duration) Duration
- func NewDurationFromTimes(a, b Time) Duration
- func (x Duration) Add(other Duration) Duration
- func (x Duration) AsAbsClock() string
- func (x Duration) AsAbsRawClock() string
- func (x Duration) AsClock() string
- func (x Duration) AsFrac(lang *language.Tag) string
- func (x Duration) AsHours() float64
- func (x Duration) AsMinutes() int
- func (x Duration) AsRawClock() string
- func (x Duration) AsRawFrac(lang *language.Tag) string
- func (x Duration) AsSignedClock() string
- func (x Duration) AsTime() time.Duration
- func (x Duration) AsUnicode() string
- func (x Duration) Equals(other Duration) bool
- func (x Duration) Format(layout string) string
- func (x *Duration) Hours() int
- func (x Duration) IsNegative() bool
- func (x Duration) IsPositive() bool
- func (x Duration) IsZero() bool
- func (x Duration) MarshalJSON() ([]byte, error)
- func (x *Duration) Minutes() int
- func (x *Duration) Parse(input string) error
- func (x Duration) RoundedBy(rounding float64) Duration
- func (x Duration) RoundedDownBy(rounding float64) Duration
- func (x Duration) RoundedUpBy(rounding float64) Duration
- func (x Duration) String() string
- func (x Duration) Sub(other Duration) Duration
- func (x Duration) UnmarshalJSON(data []byte) error
- type Month
- func (x Month) After(other Month) bool
- func (x Month) Before(other Month) bool
- func (x Month) Beginning(loc *time.Location) time.Time
- func (x Month) End(loc *time.Location) time.Time
- func (x Month) Equals(other Month) bool
- func (x Month) HumanString() string
- func (x Month) IsCurrent(referenceDate time.Time) bool
- func (x Month) Month() time.Month
- func (x Month) MonthNumber() int
- func (x Month) MonthsUntil(other Month) []Month
- func (x Month) String() string
- func (x Month) WithAddedMonths(monthCount int) Month
- func (x Month) Year() int
- type Time
- func (t *Time) After(o *Time) bool
- func (t *Time) AfterEqual(o *Time) bool
- func (t *Time) AsClock() string
- func (t *Time) AsLongClock() string
- func (t *Time) Before(o *Time) bool
- func (t *Time) BeforeEqual(o *Time) bool
- func (t *Time) Diff(o *Time) Duration
- func (t *Time) MinutesSinceMidnight() int
- func (t *Time) Parse(input string) error
- func (t *Time) String() string
- type TimeRange
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsValidTime ¶
Types ¶
type Date ¶
type Date struct {
// contains filtered or unexported fields
}
Date is a single day with no relevant time of day.
func NewDateFromTime ¶
NewDateFromTime creates a new Date from a standard library time.Time.
func ParseDate ¶
ParseDate parses a string as a date. Supported formats:
- YYYY-MM-DD
- today, yesterday, tomorrow
- -2, +4 (days from now)
func (Date) MarshalJSON ¶
func (Date) UnmarshalJSON ¶
type Duration ¶
type Duration struct {
// contains filtered or unexported fields
}
Duration is an immutable description of a minute-scale time duration.
func MustNewDurationFromString ¶
MustNewDurationFromString creates a Duration from a given string, panicking if it fails.
func NewDurationFromHours ¶
NewDurationFromHours creates a Duration from a given number of hours.
func NewDurationFromMinutes ¶
NewDurationFromMinutes creates a Duration from a given number of minutes.
func NewDurationFromString ¶
NewDurationFromString creates a Duration from a given string.
func NewDurationFromTime ¶
NewDurationFromTime creates a new Duration from a time.Duration.
func NewDurationFromTimes ¶
NewDurationFromTimes creates a Duration from two Time's. Assumed to be forward in time, a < b.
func (Duration) AsAbsClock ¶
func (Duration) AsAbsRawClock ¶
func (Duration) AsRawClock ¶
func (Duration) AsSignedClock ¶
func (Duration) Format ¶
Format allows to format a duration similar to time.Format. Valid elements are
3: hours part |3: absolute hours part +3: hours part with forced sign indicator (also show +) 04: minutes part with 0 padding to 2 characters if necessary 4: minutes part 07: minutes part as percentage with maximum 2 characters 0-: minutes part as percentage with maximum 2 characters, but minimal length too 184: total minutes
func (Duration) IsNegative ¶
IsNegative returns true if the Duration is negative.
func (Duration) IsPositive ¶
IsPositive returns true if the Duration is positive.
func (Duration) MarshalJSON ¶
func (*Duration) Minutes ¶
Minutes returns the number of minutes in this Duration, without full hours.
func (Duration) RoundedBy ¶
RoundedBy returns a new Duration rounded to the next value given by a number of minutes or a fraction of on hour (for values <= 1). Make sure to only use values that cleanly split the 60 minutes of an hour like 15 (=0.25), 20 (=0.33), 30 (=0.5) or 60 (= 1).
func (Duration) RoundedDownBy ¶
RoundedDownBy returns a new Duration rounded down to the next value given by a number of minutes or a fraction of on hour (for values <= 1). Make sure to only use values that cleanly split the 60 minutes of an hour like 15 (=0.25), 20 (=0.33), 30 (=0.5) or 60 (= 1). Also see RoundedBy.
func (Duration) RoundedUpBy ¶
RoundedUpBy returns a new Duration rounded down to the next value given by a number of minutes or a fraction of on hour (for values <= 1). Also see RoundedBy.
func (Duration) UnmarshalJSON ¶
type Month ¶
type Month struct {
// contains filtered or unexported fields
}
Month is a month in a year. Supports navigating back and forth as well as printing in different styles.
func MustNewMonth ¶
func NewMonthFromTime ¶
func (Month) HumanString ¶
func (Month) MonthNumber ¶
func (Month) MonthsUntil ¶
MonthsUntil returns all months between this one and the given (later) Month, including both of them.
func (Month) WithAddedMonths ¶
type Time ¶
Time denotes a time within a day.
func MustNewTimeParsed ¶
MustNewTimeParsed creates a new Time from a string, panicking if that does not work.
func MustNewTimeParsedPointer ¶
MustNewTimeParsedPointer creates a pointer to a new Time from a string, panicking if that does not work.
func NewTimeFromTime ¶
NewTimeFromTime creates a new Time by given time.Time.
func NewTimeParsed ¶
NewTimeParsed creates a new Time from a string.
func (*Time) AfterEqual ¶
AfterEqual returns true if this Time is after another time or they are the same.
func (*Time) AsLongClock ¶
AsLongClock returns this Time as a string like 09:25.
func (*Time) BeforeEqual ¶
BeforeEqual returns true if this Time is before another time or they are the same.
func (*Time) MinutesSinceMidnight ¶
MinutesSinceMidnight returns the number of minutes that have passed to this Time since midnight.
type TimeRange ¶
TimeRange is a pair of start and end time while both are optional.