parltime

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2022 License: ISC Imports: 3 Imported by: 0

Documentation

Overview

Package parltime provides time utility functions

Index

Constants

View Source
const (

	// RFC3339NanoSpace RFC3339 format, ns precision, space separator
	RFC3339NanoSpace string = "2006-01-02 15:04:05.999999999Z07:00"
)

Variables

This section is empty.

Functions

func Duro

func Duro(period time.Duration, timeZone Tz, atTime time.Time) (d time.Duration)

Duro calculates how much time is left of period

func GetTimeString

func GetTimeString(wallTime *time.Time) (s string)

GetTimeString rfc 3339: email time format 2020-12-04 20:20:17-08:00

func Ms

func Ms(d time.Duration) string

Ms gets duration in milliseconds

func Ns

func Ns(t time.Time) string

Ns converts time to string with nanosecond accuracy and UTC location

func NsLocal

func NsLocal(t time.Time) string

NsLocal converts time to string with nanosecond accuracy and local time zone

func OnTimer

func OnTimer(period time.Duration, timeZone Tz) (timer *time.Timer)

OnTimer waits to the next on-the-hour like period

func OnTimerLocal

func OnTimerLocal(period time.Duration) (timer *time.Timer)

OnTimerLocal waits to the next on-the-hour like period

func OnTimerUTC

func OnTimerUTC(period time.Duration) (timer *time.Timer)

OnTimerUTC waits to the next on-the-hour like period

func ParseNs

func ParseNs(timeString string) (t time.Time, err error)

ParseNs parses an RFC3339 time string with nanosecond accuracy

func ParseS

func ParseS(timeString string) (t time.Time, err error)

ParseS parses an RFC3339 time string with nanosecond accuracy

func ParseTime

func ParseTime(dateString string) (tm time.Time, err error)

ParseTime parses output from Rfc3339

func Rfc3339

func Rfc3339(t time.Time) string

Rfc3339 converts local time to string with second precision and time offset: 2006-01-02 15:04:05-07:00

func S

func S(t time.Time) string

S converts time to string with second accuracy and UTC location

func SGreater

func SGreater(t1 time.Time, t2 time.Time) bool

SGreater compares two times first rouding to second

Types

type Alert

type Alert struct {
	time.Duration
	*time.Timer
	Fired bool
}

Alert impelemnts a renewable alert timer

func NewAlert

func NewAlert(d time.Duration) (al *Alert)

NewAlert allocates a renewable alert time

func (*Alert) Start

func (al *Alert) Start()

Start initializes a new alert period

func (*Alert) Stop

func (al *Alert) Stop()

Stop releases resources associated with this alert

type OnTimed

type OnTimed struct {
	// contains filtered or unexported fields
}

OnTimed provides events to perform on the hour

func GetTimer

func GetTimer(period time.Duration, timeZone Tz, ctx context.Context) (ot *OnTimed)

func NewOnTimed

func NewOnTimed(period time.Duration) (ot *OnTimed)

NewOnTimed provides events to perform on the hour

func NewOnTimedLocal

func NewOnTimedLocal(period time.Duration) (ot *OnTimed)

NewOnTimedLocal provides events to perform on the hour

func (*OnTimed) Chan

func (ot *OnTimed) Chan() (ch <-chan time.Time)

Chan gets a channel to wait for

func (*OnTimed) Close

func (ot *OnTimed) Close()

Close stop the durations

type Tz

type Tz byte

Tz indicates what time zone to use

const (
	// UTC time zone
	UTC Tz = iota
	// LOCAL time zone
	LOCAL
)

Jump to

Keyboard shortcuts

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