timeext

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2022 License: Apache-2.0 Imports: 4 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(v int) time.Duration

func FromHoursFloat64

func FromHoursFloat64(v float64) time.Duration

func FromMilliseconds

func FromMilliseconds(v int) time.Duration

func FromMillisecondsFloat

func FromMillisecondsFloat(v float64) time.Duration

func FromMinutes

func FromMinutes(v int) time.Duration

func FromMinutesFloat

func FromMinutesFloat(v float64) time.Duration

func FromMinutesFloat64

func FromMinutesFloat64(v float64) time.Duration

func FromSeconds

func FromSeconds(v int) time.Duration

func FromSecondsFloat

func FromSecondsFloat(v float64) time.Duration

func FromSecondsFloat32

func FromSecondsFloat32(v float32) time.Duration

func FromSecondsFloat64

func FromSecondsFloat64(v float64) time.Duration

func FromSecondsInt32

func FromSecondsInt32(v int32) time.Duration

func FromSecondsInt64

func FromSecondsInt64(v int64) 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 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