timeext

package
v0.0.125 Latest Latest
Warning

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

Go to latest
Published: May 28, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TimezoneBerlin *time.Location

Functions

func CombineDateAndTime

func CombineDateAndTime(d time.Time, t time.Time) time.Time

CombineDateAndTime returns a timestamp with the date-part (`yyyy`, `MM`, `dd`) from the d parameter and the time (`HH`, `mm`, `ss`) from the t parameter

func DurationFromTime

func DurationFromTime(hours int, minutes int, seconds int) time.Duration

func FloorTime added in v0.0.10

func FloorTime(t time.Time) time.Time

func FormatNaturalDurationEnglish added in v0.0.5

func FormatNaturalDurationEnglish(iv time.Duration) string

func FromDays

func FromDays[T langext.NumberConstraint](v T) time.Duration

func FromHours added in v0.0.22

func FromHours[T langext.NumberConstraint](v T) time.Duration

func FromMicroseconds added in v0.0.22

func FromMicroseconds[T langext.NumberConstraint](v T) time.Duration

func FromMilliseconds

func FromMilliseconds[T langext.NumberConstraint](v T) time.Duration

func FromMinutes

func FromMinutes[T langext.NumberConstraint](v T) time.Duration

func FromNanoseconds added in v0.0.22

func FromNanoseconds[T langext.NumberConstraint](v T) time.Duration

func FromSeconds

func FromSeconds[T langext.NumberConstraint](v T) time.Duration

func GetAggregateIsoWeekCount

func GetAggregateIsoWeekCount(year int) int

func GetGlobalWeeknumber

func GetGlobalWeeknumber(t time.Time) int

func GetIsoWeekCount

func GetIsoWeekCount(year int) int

func IsDatePartEqual

func IsDatePartEqual(a time.Time, b time.Time, tz *time.Location) bool

IsDatePartEqual returns true if a and b have the same date part (`yyyy`, `MM` and `dd`)

func IsSameDayIncludingDateBoundaries

func IsSameDayIncludingDateBoundaries(t1 time.Time, t2 time.Time, tz *time.Location) bool

IsSameDayIncludingDateBoundaries returns true if t1 and t2 are part of the same day (TZ/Berlin), the boundaries of the day are inclusive, this means 2021-09-15T00:00:00 is still part of the day 2021-09-14

func IsSunday

func IsSunday(t time.Time, tz *time.Location) bool

IsSunday returns true if t is a sunday (in TZ/Berlin)

func Max

func Max(a time.Time, b time.Time) time.Time

func Min

func Min(a time.Time, b time.Time) time.Time

func ParseDurationShortString added in v0.0.29

func ParseDurationShortString(s string) (time.Duration, error)

ParseDurationShortString parses a duration in string format to a time.Duration Examples for allowed formats:

  • '10m'
  • '10min'
  • '1minute'
  • '10minutes'
  • '10.5minutes'
  • '50s'
  • '50sec'
  • '1second'
  • '50seconds'
  • '100ms'
  • '100millisseconds'
  • '1h'
  • '1hour'
  • '2hours'
  • '1d'
  • '1day'
  • '10days'
  • '1d10m'
  • '1d10m200sec'
  • '1d:10m'
  • '1d 10m'
  • '1d,10m'

func TimeToDatePart

func TimeToDatePart(t time.Time, tz *time.Location) time.Time

TimeToDatePart returns a timestamp at the start of the day which contains t (= 00:00:00)

func TimeToMonthEnd

func TimeToMonthEnd(t time.Time, tz *time.Location) time.Time

TimeToMonthEnd returns a timestamp at the end of the month which contains t (= yyyy-MM-31 23:59:59.999999999)

func TimeToMonthStart

func TimeToMonthStart(t time.Time, tz *time.Location) time.Time

TimeToMonthStart returns a timestamp at the start of the month which contains t (= yyyy-MM-00 00:00:00)

func TimeToWeekStart

func TimeToWeekStart(t time.Time, tz *time.Location) time.Time

TimeToWeekStart returns a timestamp at the start of the week which contains t (= Monday 00:00:00)

func TimeToYearEnd

func TimeToYearEnd(t time.Time, tz *time.Location) time.Time

TimeToYearEnd returns a timestamp at the end of the month which contains t (= yyyy-12-31 23:59:59.999999999)

func TimeToYearStart

func TimeToYearStart(t time.Time, tz *time.Location) time.Time

TimeToYearStart returns a timestamp at the start of the year which contains t (= yyyy-01-01 00:00:00)

func UnixFloatSeconds

func UnixFloatSeconds(v float64) time.Time

func WeekdayNameGerman

func WeekdayNameGerman(d time.Weekday) string

func WithTimePart

func WithTimePart(base time.Time, hour, minute, second int) time.Time

WithTimePart returns a timestamp with the date-part (`yyyy`, `MM`, `dd`) from base and the time (`HH`, `mm`, `ss`) from the parameter

Types

type OpenTimeRange

type OpenTimeRange struct {
	From *time.Time
	To   *time.Time
}

func NewOpenTimeRange

func NewOpenTimeRange(from *time.Time, to *time.Time) *OpenTimeRange

func (*OpenTimeRange) AppendToMongoPipeline

func (r *OpenTimeRange) AppendToMongoPipeline(pipeline []interface{}, key string) []interface{}

func (OpenTimeRange) Contains

func (r OpenTimeRange) Contains(v time.Time) bool

func (OpenTimeRange) String

func (r OpenTimeRange) String() string

func (OpenTimeRange) ToMongoPipeline

func (r OpenTimeRange) ToMongoPipeline(key string) []interface{}

Jump to

Keyboard shortcuts

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