Documentation
¶
Overview ¶
Package timeconv provides some simple function to convert go time.Time values. Please refer to functions below.
Example ¶
package main
import (
"fmt"
timeconv "github.com/Andrew-M-C/go.timeconv"
)
func main() {
p := fmt.Println
t := timeconv.Date(2020, 1, 31)
p(t)
p(t.AddDate(0, 1, 0))
p(timeconv.AddDate(t, 0, 1, 0))
}
Output: 2020-01-31 00:00:00 +0000 UTC 2020-03-02 00:00:00 +0000 UTC 2020-02-29 00:00:00 +0000 UTC
Index ¶
- func AddDate(t time.Time, years, months, days int) time.Time
- func AddDateP(t *time.Time, years, months, days int)
- func Date(year int, month time.Month, day int, loc ...*time.Location) time.Time
- func HHMM(t time.Time, seperator string) string
- func HHMMSS(t time.Time, seperator string, decimal ...int) string
- func ProcUpDuration() time.Duration
- func UnixMicro(t time.Time) int64
- func UnixMilli(t time.Time) int64
- func YYMMDD(t time.Time, seperator string) string
- func YYYYMMDD(t time.Time, seperator string) string
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddDate ¶
AddDate returns the time corresponding to adding the given number of years, months, and days to t. For example, AddDate(-1, 2, 3) applied to January 1, 2011 returns March 4, 2010.
However, this version of AddDate will examine the date of month. For example, AddDate(0, 1, 0) applied to January 31, 2011 returns Feburary 28, 2011 instead of March 3, 2011.
func Date ¶ added in v0.2.0
Date returns a time.Time value with year, month, day and location only. If not indecating loc, UTC will be used.
func HHMMSS ¶ added in v0.4.0
HHMMSS is equivalent to t.Format(fmt.Sprintf("03%s04%s05", seperator, seperator)). With decimal, additional decimal digits of seconds will be added after a dot.
func ProcUpDuration ¶ added in v0.3.0
ProcUpDuration returns a rough duration indecating how long current process has run.
Types ¶
This section is empty.