v0.0.246 timeext
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 1m11s

This commit is contained in:
Mike Schwörer 2023-08-21 14:15:06 +02:00
parent 39a0b73d56
commit ec9ac26a4c
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF
2 changed files with 13 additions and 2 deletions

View File

@ -1,5 +1,5 @@
package goext
const GoextVersion = "0.0.245"
const GoextVersion = "0.0.246"
const GoextVersionTimestamp = "2023-08-21T13:27:36+0200"
const GoextVersionTimestamp = "2023-08-21T14:15:06+0200"

View File

@ -22,6 +22,17 @@ func TimeToDatePart(t time.Time, tz *time.Location) time.Time {
return time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location())
}
// TimeToDayStart returns a timestamp at the start of the day which contains t (= 00:00:00)
func TimeToDayStart(t time.Time, tz *time.Location) time.Time {
t = t.In(tz)
return time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location())
}
// TimeToDayEnd returns a timestamp at the end of the day which contains t (= 23:59:59)
func TimeToDayEnd(t time.Time, tz *time.Location) time.Time {
return TimeToDayStart(t, tz).AddDate(0, 1, 0).Add(-1)
}
// TimeToWeekStart returns a timestamp at the start of the week which contains t (= Monday 00:00:00)
func TimeToWeekStart(t time.Time, tz *time.Location) time.Time {
t = TimeToDatePart(t, tz)