time

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2025 License: GPL-3.0 Imports: 4 Imported by: 2

README

Time

A simple library to work with time in Go programming language.

Documentation

Index

Constants

View Source
const FormatDayTimeString = "2006-01-02"

FormatDayTimeString is the format of day time, i.e. a day identifier.

View Source
const (
	// TimeFormatFor_GetLocationOffset is the time format for the
	// 'GetLocationOffset' function.
	TimeFormatFor_GetLocationOffset = "2006-01-02 15:04:05"
)

Settings for internal usage.

Variables

This section is empty.

Functions

func AddHours

func AddHours(timeStart time.Time, deltaHours *big.Rat) time.Time

AddHours adds hours to the time.

func GetLocationOffset added in v0.8.5

func GetLocationOffset(location *time.Location) (timeOffset time.Duration, err error)

GetLocationOffset gets the time offset of a location as duration.

func HoursToDuration added in v0.8.5

func HoursToDuration(hours *big.Rat) time.Duration

HoursToDuration converts hours into duration. Why ? In Go language it is impossible to simply get a 1/3 of an hour. Moreover, a float32 number storing a 1/3 will always have an error due to its binary nature.

func IntervalDurationHours

func IntervalDurationHours(timeStart time.Time, timeEnd time.Time) (delta *big.Rat)

IntervalDurationHours calculates the interval duration between two specified time values in hours.

func IsEmpty

func IsEmpty(t time.Time) bool

IsEmpty tells whether the time is empty or not.

func Maximum

func Maximum(a time.Time, b time.Time) time.Time

Maximum selects the maximum time of the two specified.

func Minimum

func Minimum(a time.Time, b time.Time) time.Time

Minimum selects the minimum time of the two specified.

func NewTimeStringRFC3339

func NewTimeStringRFC3339(year uint, month uint, day uint, hour uint, minute uint, second uint) string

NewTimeStringRFC3339 creates a new time string using the RFC3339.

func ParseDayTimeStringInLocation

func ParseDayTimeStringInLocation(dayTimeString string, location *time.Location) (dayStartTime time.Time, err error)

ParseDayTimeStringInLocation parses time string in the location.

func SubHours

func SubHours(timeStart time.Time, deltaHours *big.Rat) time.Time

SubHours subtracts hours from the time.

func ToDayStart

func ToDayStart(t time.Time) time.Time

ToDayStart returns time rounded to days, i.e. all the sub-day data is rounded to a day's start.

func ToHourStart

func ToHourStart(t time.Time) time.Time

ToHourStart returns time rounded to hours, i.e. all the sub-hour data is rounded to an hour's start.

func ToMinuteStart

func ToMinuteStart(t time.Time) time.Time

ToMinuteStart returns time rounded to minutes, i.e. all the sub-minute data is rounded to a minute's start.

func ToMonthStart

func ToMonthStart(t time.Time) time.Time

ToMonthStart returns time rounded to months, i.e. all the sub-month data is rounded to a month's start.

func ToNextMonthStart

func ToNextMonthStart(t time.Time) time.Time

ToNextMonthStart shifts the time to the start of the next month.

func ToPreviousMonthStart

func ToPreviousMonthStart(t time.Time) time.Time

ToPreviousMonthStart shifts the time to the start of the previous month.

func ToSecondStart added in v0.8.5

func ToSecondStart(t time.Time) time.Time

ToSecondStart returns time rounded to seconds, i.e. all the sub-second data is rounded to a second's start.

Types

This section is empty.

Jump to

Keyboard shortcuts

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