clock

package
v0.5.69 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2026 License: MIT Imports: 4 Imported by: 1

Documentation

Overview

Package clock contains time and date-related functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CurrentTimezone

func CurrentTimezone() *time.Location

Get current timezone location object

func DateFormat

func DateFormat(t time.Time) string

Format given time in date format (yyyy-mm-dd)

func DateNow

func DateNow() string

Return current date in yyyy-mm-dd format

func DateTimeEnd

func DateTimeEnd(date string) string

Attach 23:59:59 to given date

func DateTimeNow

func DateTimeNow() string

Return current datetime in standard format (yyyy-mm-dd hh:mm:ss)

func DateTimeNowWithExpiry

func DateTimeNowWithExpiry(duration time.Duration) (now, expiry string)

Return datetime now and expiry datetime (based on given duration), Both in standard format (yyyy-mm-dd hh:mm:ss)

func DateTimeStart

func DateTimeStart(date string) string

Attach 00:00:00 to given date

func DurationSince

func DurationSince(datetime string, round time.Duration) (string, error)

Calculate duration since given datetime, rounded to given duration Return duration as string

func ElapsedSince added in v0.5.35

func ElapsedSince(datetime string) (time.Duration, error)

Calculate duration since given datetime

func ExtendTime

func ExtendTime(datetime string, duration time.Duration) (string, error)

Extend given datetime with given duration, Return extended time in standard format (yyyy-mm-dd hh:mm:ss)

func ExtractDate

func ExtractDate(datetime string) string

Extracts date from datetime string

func ExtractTime added in v0.5.30

func ExtractTime(datetime string) string

Extracts time from datetime string

func HourMinFormat

func HourMinFormat(t time.Time) string

Format given time in hh:mm format

func HourMinNow

func HourMinNow() string

Return current hour and minute in hh:mm format

func IsExpired

func IsExpired(expiry string) bool

Check if given datetime is already expired (before current time)

func IsMidnight

func IsMidnight() bool

Check if hour:minute now is 00:00 (midnight)

func IsValidDate

func IsValidDate(date string) bool

Check if given yyyy-mm-dd date is valid

func IsValidDateTime

func IsValidDateTime(datetime string) bool

Check if given datetime in standard format is valid

func MidnightToday

func MidnightToday() string

Return midnight datetime today in standard format (yyyy-mm-dd hh:mm:ss)

func Now

func Now() time.Time

Returns current time in current timezone

func Parse added in v0.5.61

func Parse(datetime, format string) (time.Time, error)

Parse given string as datetime in given format, in current timezone

func ParseDateTime

func ParseDateTime(datetime string) (time.Time, error)

Parse given string as datetime in standard format, in current timezone

func RunForever

func RunForever()

Run infinite loop; used for main() with goroutines

func SetTimezone

func SetTimezone(newTimezone string) error

Override current timezone

func Sleep

func Sleep(pause time.Duration, start time.Time)

Pauses for given duration, taking into account the starting time, adjusting the pause duration

func StandardFormat

func StandardFormat(t time.Time) string

Format given time in standard format (yyyy-mm-dd hh:mm:ss)

func TimeFormat

func TimeFormat(t time.Time) string

Format given time in time format (hh:mm:ss)

func TimeNow

func TimeNow() string

Return current time in hh:mm:ss format

func TimestampFormat

func TimestampFormat(t time.Time) string

Format given time in timestamp format (yymmddhhmmss)

func TimestampNow

func TimestampNow() string

Return current datetime in timestamp format (yymmddhhmmss)

Types

This section is empty.

Jump to

Keyboard shortcuts

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