timeutil

package
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package timeutil provides utility functions and types for working with time-related operations.

Index

Constants

View Source
const (
	HoursInADay      = 24
	MaxHoursInAMonth = 744  // 31 day months
	MaxHoursInAYear  = 8784 // Leap years
)

Variables

Functions

func DayFormat

func DayFormat(t time.Time) int

func DaysIn

func DaysIn(t time.Time) int

DaysIn returns the number of days in the month for the specified time.

func FromStr

func FromStr(timeStr string) (time.Time, error)

func MinsToHoursAndMins

func MinsToHoursAndMins(val int) (hrs, mins int)

MinsToHoursAndMins expresses a minutes value in hours and mins.

func Round

func Round(t float64) int

Round rounds a time value in seconds, minutes, or hours to the nearest integer.

func RoundToEnd

func RoundToEnd(t time.Time) time.Time

RoundToEnd resets the given time to the end of the day.

func RoundToStart

func RoundToStart(t time.Time) time.Time

RoundToStart resets the given time to the start of the day.

func ToKey

func ToKey(t time.Time) []byte

ToKey converts a time value to a database key for Bolt.

Types

type Period

type Period string
const (
	PeriodAllTime   Period = "all-time"
	PeriodToday     Period = "today"
	PeriodYesterday Period = "yesterday"
	Period7Days     Period = "7days"
	Period14Days    Period = "14days"
	Period30Days    Period = "30days"
	Period90Days    Period = "90days"
	Period180Days   Period = "180days"
	Period365Days   Period = "365days"
)

Jump to

Keyboard shortcuts

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