xtime

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2017 License: MIT Imports: 4 Imported by: 12

Documentation

Index

Constants

View Source
const DateFmt = "2006-01-02"

DateFmt is a fairly standard, date-only format for times.

Variables

This section is empty.

Functions

func Date

func Date(datetime time.Time) time.Time

Date returns a given time, without any time on it. Only the date.

func FormatDuration

func FormatDuration(duration time.Duration, timeFormat DurationFormat) string

FormatDuration returns the given time.Duration as a string in the given DurationFormat.

func LastWeekday

func LastWeekday(weekday time.Weekday) time.Time

LastWeekday finds the date of the most recent occurrence of a given weekday in the past.

Types

type DurationFormat

type DurationFormat int

DurationFormat is an "enum" of the different display time formats. A DurationFormat can be used in conjunction with FormatDuration to control how some output duration is displayed.

const (
	FormatDecimal DurationFormat = iota
	FormatText
)

All possible duration formats.

func (*DurationFormat) UnmarshalTOML

func (f *DurationFormat) UnmarshalTOML(bytes []byte) error

UnmarshalTOML takes a raw TOML time format value and attempts to parse the value as a DurationFormat. The value passed to this method should be a byte array of a quoted string (i.e. the raw TOML value), the method will remove the quotes.

type Weekday

type Weekday time.Weekday

Weekday is a type used to extend the built-in 'time.Weekday' type to add new methods to help with things like parsing weekday strings into a stricter type.

const (
	Sunday Weekday = iota
	Monday
	Tuesday
	Wednesday
	Thursday
	Friday
	Saturday
)

All possible Weekday values.

func (Weekday) TimeWeekday

func (w Weekday) TimeWeekday() time.Weekday

TimeWeekday converts this Weekday to a standard library time.Weekday.

func (*Weekday) UnmarshalTOML

func (w *Weekday) UnmarshalTOML(bytes []byte) error

UnmarshalTOML takes a raw TOML weekday string value and attempts to parse the value as a Weekday. The value passed to this method should be a byte array of a quoted string (i.e. the raw TOML value), the method will remove the quotes.

Jump to

Keyboard shortcuts

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