dateutil

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2025 License: MIT Imports: 3 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package dateutil provides a custom flag for dates.

Index

Constants

This section is empty.

Variables

View Source
var (
	// EveryMinute will chop up a timespan into 60s intervals;
	// https://english.stackexchange.com/questions/3091/weekly-daily-hourly-minutely.
	EveryMinute = makeIntervalFunc(
		func(t time.Time) time.Time { return now.With(t).BeginningOfMinute() },
		func(t time.Time) time.Time { return now.With(t).EndOfMinute() },
	)
	// Hourly will chop up a timespan into 60min intervals.
	Hourly = makeIntervalFunc(
		func(t time.Time) time.Time { return now.With(t).BeginningOfHour() },
		func(t time.Time) time.Time { return now.With(t).EndOfHour() },
	)
	// Daily will chop up a timespan into 24h intervals.
	Daily = makeIntervalFunc(
		func(t time.Time) time.Time { return now.With(t).BeginningOfDay() },
		func(t time.Time) time.Time { return now.With(t).EndOfDay() },
	)
	// Weekly will chop up a timespan into 7 day intervals.
	Weekly = makeIntervalFunc(
		func(t time.Time) time.Time { return now.With(t).BeginningOfWeek() },
		func(t time.Time) time.Time { return now.With(t).EndOfWeek() },
	)
	// Monthly will chop up a timespan into monthly intervals.
	Monthly = makeIntervalFunc(
		func(t time.Time) time.Time { return now.With(t).BeginningOfMonth() },
		func(t time.Time) time.Time { return now.With(t).EndOfMonth() },
	)
)

Functions

func MustParse

func MustParse(value string) time.Time

MustParse will panic on an unparsable date string.

Types

type Date

type Date struct {
	time.Time
}

Date can be used to parse command line args into dates.

func (*Date) Set

func (d *Date) Set(value string) error

Set parses a value into a date, relatively flexible due to araddon/dateparse, 2014-04-26 will work, but oct. 7, 1970, too.

func (*Date) String

func (d *Date) String() string

String returns a formatted date.

type Interval

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

Interval groups start and end.

Jump to

Keyboard shortcuts

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