dateutil

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package dateutil provides interval handling.

Index

Constants

This section is empty.

Variables

View Source
var (
	// EveryMinute will chop up a timespan into 60s intervals;
	// https://english.stackexchange.com/q/3091/222
	EveryMinute = makeIntervalFunc(padLMinute, padRMinute)
	Hourly      = makeIntervalFunc(padLHour, padRHour)
	Daily       = makeIntervalFunc(padLDay, padRDay)
	Weekly      = makeIntervalFunc(padLWeek, padRWeek)
	Biweekly    = makeIntervalFunc(padLBiweek, padRBiweek)
	Monthly     = makeIntervalFunc(padLMonth, padRMonth)
)

Functions

func MustParse

func MustParse(value string) time.Time

MustParse is like Parse but panics on error

func Parse

func Parse(value string) (time.Time, error)

Types

type Interval

type Interval struct {
	Start time.Time
	End   time.Time
}

Interval groups start and end.

func (Interval) String

func (iv Interval) String() string

String renders an interval.

func (Interval) Validate

func (iv Interval) Validate() error

Validate checks if the interval is valid (end after start)

type IntervalFunc

type IntervalFunc func(s, e time.Time) []Interval

IntervalFunc takes a start and endtime and returns a number of intervals. How intervals are generated is flexible.

type PadFunc

type PadFunc func(t time.Time) time.Time

PadFunc allows to move a given time back and forth.

Jump to

Keyboard shortcuts

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