clock

package
v0.3.27 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package clock contains time and date-related functions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DateTimeEnd added in v0.3.26

func DateTimeEnd(date Date) string

DateTimeEnd attaches 23:59:59 to given date

func DateTimeStart added in v0.3.26

func DateTimeStart(date Date) string

DateTimeStart attaches 00:00:00 to given date

func DurationSince added in v0.3.26

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

DurationSince returns the duration as string since given datetime, rounded to given duration

func ElapsedSince added in v0.3.26

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

ElapsedSince returns the duration since given datetime

func ExtendTime added in v0.3.26

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

ExtendTime returns the extended time in standard format

func ExtractDate added in v0.3.26

func ExtractDate(datetime string) string

ExtractDate returns the date part of the given datetime string

func ExtractTime added in v0.3.26

func ExtractTime(datetime string) string

ExtractTime extracts time part from given datetime string

func ExtractYearMonth added in v0.3.26

func ExtractYearMonth(datetime string) string

ExtractYearMonth returns the year and month part of the given datetime string

func HourMinFormat

func HourMinFormat(t time.Time) string

HourMinFormat formats the given time in hh:mm format

func HourMinNow added in v0.3.26

func HourMinNow() string

HourMinNow returns the current time in hh:mm format

func IsExpired added in v0.3.26

func IsExpired(expiry string) bool

IsExpired checks if given datetime is already expired (before current time)

func IsValidDate added in v0.3.26

func IsValidDate(date string) bool

IsValidDate checks if given yyyy-mm-dd date is valid

func IsValidDateTime added in v0.3.26

func IsValidDateTime(datetime string) bool

IsValidDateTime checks if given datetime in standard format is valid

func Parse added in v0.3.26

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

Parse the given string as datetime in given format

func ParseDateTime added in v0.3.26

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

ParseDateTime parses the given string as datetime in standard format

func Sleep

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

Sleep pauses for a given duration, given the start time

func TimestampFormat

func TimestampFormat(t time.Time) string

TimestampFormat formats the given time in timestamp format (yymmddhhmmss)

Types

type Date

type Date = string

func DateFormat

func DateFormat(t time.Time) Date

DateFormat formats the given time in date format (yyyy-mm-dd)

func DateNow added in v0.3.26

func DateNow() Date

DateNow returns the current date in yyyy-mm-dd format

type DateTime

type DateTime = string

func DateTimeNow

func DateTimeNow() DateTime

DateTimeNow returns the current datetime in standard format

func DateTimeNowWithExpiry added in v0.3.26

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

DateTimeNowWithExpiry returns current datetime and expiry datetime in standard format

func StandardFormat

func StandardFormat(t time.Time) DateTime

StandardFormat formats the given time in standard format (yyyy-mm-dd hh:mm:ss)

func TimestampNow added in v0.3.23

func TimestampNow() DateTime

TimestampNow returns the current datetime in timestamp format

type Time

type Time = string

func TimeFormat

func TimeFormat(t time.Time) Time

TimeFormat formats the given time in time format (hh:mm:ss)

func TimeNow added in v0.3.26

func TimeNow() Time

TimeNow returns the current time in hh:mm:ss format

Jump to

Keyboard shortcuts

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