time

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// YearMonthDay is a time format similar to RFC3339 with day granularity
	// instead of second.
	YearMonthDay = "2006-01-02"
	// YearMonthDayHour is a time format similar to RFC3339 with hour
	// granularity instead of second.
	YearMonthDayHour = "2006-01-02T15Z07:00"
	// YearMonthDayHourMinute is a time format similar to RFC3339 with minute
	// granularity instead of second.
	YearMonthDayHourMinute = "2006-01-02T15:04Z07:00"
	// RFC3339Milli is a time format layout for use in time.Format and
	// time.Parse. It follows the RFC3339 format with millisecond precision.
	RFC3339Milli = "2006-01-02T15:04:05.999Z07:00"
	// RFC3339Micro is a time format layout for use in time.Format and
	// time.Parse. It follows the RFC3339 format with microsecond precision.
	RFC3339Micro = "2006-01-02T15:04:05.999999Z07:00"
)

Variables

View Source
var FormatNames = []string{
	"YearMonthDay",
	"YearMonthDayHour",
	"YearMonthDayHourMinute",
	"StampMilli",
	"RFC3339",
	"RFC3339Milli",
	"RFC3339Micro",
	"RFC3339Nano",
	"RFC1123Z",
}

FormatNames are the valid time format names accepted by this package.

View Source
var (
	// Now is a hijackable function for time.Now() that makes unit testing a lot
	// easier for stuff that relies on relative time.
	Now = time.Now
)

Functions

func FormatNameToLayout added in v0.8.0

func FormatNameToLayout(name string) string

FormatNameToLayout returns the time format layout for the time format name.

func FromString

func FromString(input string) (time.Time, error)

FromString takes as input a string in either RFC3339 or time.Duration format in the past and converts it to a time.Time.

Types

This section is empty.

Jump to

Keyboard shortcuts

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