date

package
v0.1.19 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2020 License: Apache-2.0 Imports: 5 Imported by: 16

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArbitraryDatestring2MidnightPdt

func ArbitraryDatestring2MidnightPdt(s string, fmt string) time.Time

func AtLocalMidnight

func AtLocalMidnight(in time.Time) time.Time

Legacy name, should fixup.

func DateRangeToPacificTimeWindows

func DateRangeToPacificTimeWindows(sStr, eStr string) [][]time.Time

func Datestring2MidnightPdt

func Datestring2MidnightPdt(s string) time.Time

func InPdt

func InPdt(t time.Time) time.Time

All these FooPdt functions should be renamed FooPacificTime; they're not specific to dayight savings. And in fact should be turned into LocalTime or something.

func IntermediateMidnights

func IntermediateMidnights(s, e time.Time) (ret []time.Time)

Return all midnights inbetween s & e - not including s or e if they happen to be midnight. Caller should ensure s and e are in the same timezone.

func MonthWindowForTime

func MonthWindowForTime(t time.Time) (start time.Time, end time.Time)

Get the window for all in the seconds in the month which contains the time

func NowInPdt

func NowInPdt() time.Time

func ParseInPdt

func ParseInPdt(format string, value string) (time.Time, error)

func RoundDuration

func RoundDuration(d time.Duration) time.Duration

func Time2Datestring

func Time2Datestring(t time.Time) string

func Timeslots

func Timeslots(s, e time.Time, d time.Duration) []time.Time

Returns a list of time buckets, of given duration, that the inputs span. Each bucket is returned as the time-instant that begins the bucket.

func TruncateToLocalDay

func TruncateToLocalDay(in time.Time) time.Time

Round off to 00:00:00 today (i.e. most recent midnight) Can't use time.Round(24*time.Hour); it operates in UTC, so rounds into weird boundaries

func TruncateToUTCDay

func TruncateToUTCDay(in time.Time) time.Time

Perhaps time.Round(24*time.Hour) works here ?

func WindowForTime

func WindowForTime(t time.Time) (start time.Time, end time.Time)

A 'window' is a pair of times spanning 23-25h, respecting the timezone of the input, and honoring daylight savings changes. start will be midnight (00:00:00) that day; end is 24h later, i.e. 00:00:00 the next day

func WindowForToday

func WindowForToday() (start time.Time, end time.Time)

Convenience helpers

func WindowForYesterday

func WindowForYesterday() (start time.Time, end time.Time)

func WindowsForRange

func WindowsForRange(s, e time.Time) [][]time.Time

For each distincy day in the span (s,e] we generate a window (pair of times)

Types

type TimeOfDayRange

type TimeOfDayRange struct {
	Hour, Minute int
	Length       time.Duration
}

TimeOfDayRange specifies a duration within a day

func FormValueTimeOfDayRange

func FormValueTimeOfDayRange(r *http.Request, stem string) (TimeOfDayRange, error)

If fields absent or blank, returns {0.0, 0.0}

func ParseTimeOfDay

func ParseTimeOfDay(start string, length string) (TimeOfDayRange, error)

func (TimeOfDayRange) AnchorInsideDay

func (tr TimeOfDayRange) AnchorInsideDay(t time.Time) (time.Time, time.Time)

Given an 'anchor day' t, find the start/end times of the TimeOfDay inside it. If the range straddles midnight, then 'end' will come before 'start', and will be the end of the previous day's range. Note that 't' *must* have a location defined, or this will panic().

func (TimeOfDayRange) Contains

func (tr TimeOfDayRange) Contains(t time.Time) bool

func (TimeOfDayRange) End

func (tr TimeOfDayRange) End() time.Time

func (TimeOfDayRange) IsInitialized

func (tr TimeOfDayRange) IsInitialized() bool

func (TimeOfDayRange) Overlaps

func (tr TimeOfDayRange) Overlaps(s, e time.Time) bool

func (TimeOfDayRange) Start

func (tr TimeOfDayRange) Start() time.Time

func (TimeOfDayRange) String

func (tr TimeOfDayRange) String() string

func (TimeOfDayRange) Values

func (tr TimeOfDayRange) Values() url.Values

Jump to

Keyboard shortcuts

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