Documentation ¶
Overview ¶
Package time provide a library for working with time.
Index ¶
Examples ¶
Constants ¶
const ( // Day the duration for a day. Day = 24 * time.Hour // Week the duration for a week. Week = 7 * Day )
Variables ¶
var ( ShortDayNames = []string{ "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun", } // // ShortMonths provide mapping between text of month, in English, // short format to their time.Month value // ShortMonths = map[string]time.Month{ "Jan": time.January, "Feb": time.February, "Mar": time.March, "Apr": time.April, "May": time.May, "Jun": time.June, "Jul": time.July, "Aug": time.August, "Sep": time.September, "Oct": time.October, "Nov": time.November, "Dec": time.December, } )
var ( // ErrDurationMissingValue an error when value is missing when parsing // duration. ErrDurationMissingValue = errors.New("missing value in duration") )
Functions ¶
func Microsecond ¶
Microsecond return the microsecond value of time. For example, if the unix nano seconds is 1612331218913557000 then the micro second value is 913557.
To get the unix microsecond use UnixMicro().
Example ¶
nano := time.Unix(1612331000, 123456789) fmt.Printf("%d", Microsecond(&nano))
Output: 123456
func ParseDuration ¶
ParseDuration extend the capability of standard time.Duration with additional unit suffix: day and week. Day unit end with "d" and week unit end with "w". A day is equal with "24h", an a week is equal to "7d". Unlike standard time.Duration the week or day units must be before hours.
func UnixMicro ¶ added in v0.23.0
UnixMicro returns t as a Unix time in microsecond. For example, if the unix nano seconds is 1612331218913557000 then the UnixMicro value is 1612331218913557.
Example ¶
nano := time.Unix(1612331000, 123456789) fmt.Printf("%d", UnixMicro(&nano))
Output: 1612331000123456
Types ¶
This section is empty.