times

package
v0.0.0-...-0117b6e Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: Apache-2.0 Imports: 2 Imported by: 30

Documentation

Overview

Package times provides a set of utilities related to processing time.

Index

Examples

Constants

This section is empty.

Variables

View Source
var DefaultClock = &defaultClock{}

DefaultClock implements Clock by delegating to methods in package time.

Functions

func ParseIso8601UTC

func ParseIso8601UTC(t string) time.Time

ParseIso8601UTC parses a time in Iso8601 format and UTC timezone (yyyy-MM-ddTHH:mm:ss.fffZ).

func ParseIsoDashUTC

func ParseIsoDashUTC(t string) (time.Time, error)

ParseIsoDashUTC parses a time in IsoDash format and UTC timezone (yyyy-MM-ddTHH-mm-ss.fffZ).

func ToIso8601UTC

func ToIso8601UTC(t time.Time) string

ToIso8601UTC converts a time into a string in Iso8601 format in UTC timezone (yyyy-MM-ddTHH:mm:ss.fffZ).

Example
fmt.Println(ToIso8601UTC(time.Date(2015, 6, 30, 0, 29, 4, 569000000, time.UTC)))
Output:

2015-06-30T00:29:04.569Z
Example (Locale)
mst := time.FixedZone("MST", -7*3600) // seven hours west of UTC
fmt.Println(ToIso8601UTC(time.Date(2015, 6, 3, 0, 9, 4, 569100000, mst)))
Output:

2015-06-03T07:09:04.569Z

func ToIsoDashUTC

func ToIsoDashUTC(t time.Time) string

ToIsoDashUTC converts a time into a string in Iso format yyyy-MM-ddTHH-mm-ss.fffZ in UTC timezone.

Example
fmt.Println(ToIsoDashUTC(time.Date(2015, 6, 30, 0, 29, 3, 148000000, time.UTC)))
Output:

2015-06-30T00-29-03.148Z

Types

type Clock

type Clock interface {
	// Now returns the current time.
	Now() time.Time

	// After returns a channel that will receive after the given duration.
	After(time.Duration) <-chan time.Time
}

Clock is an interface that can provide time related functionality.

Jump to

Keyboard shortcuts

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