Documentation
¶
Index ¶
- Constants
- Variables
- func AddMonth(t time.Time, m int) time.Time
- func AddYear(t time.Time, y int) time.Time
- func Atod(s string, defs ...time.Duration) time.Duration
- func HumanDuration(d time.Duration) string
- func IsLeapYear(t time.Time) bool
- func LocalFormat(a any, f string) string
- func LocalFormatDate(a any) string
- func LocalFormatDateTime(a any) string
- func LocalFormatTime(a any) string
- func NonZeroDuration(ds ...time.Duration) time.Duration
- func NonZeroTime(ts ...time.Time) time.Time
- func Parse(value string, layouts ...string) (tt time.Time, err error)
- func ParseDuration(s string) (time.Duration, error)
- func ParseInLocation(value string, loc *time.Location, layouts ...string) (tt time.Time, err error)
- func TruncateHours(t time.Time) time.Time
- func TruncateMinutes(t time.Time) time.Time
- func TruncateSeconds(t time.Time) time.Time
- type HHMM
- type MMSS
Constants ¶
const ( Nanosecond = time.Nanosecond Microsecond = time.Microsecond Millisecond = time.Millisecond Second = time.Second Minute = time.Minute Hour = time.Hour Day = time.Hour * 24 )
Variables ¶
var GeneralLayouts = []string{time.RFC3339, "2006-1-2 15:04:05", "2006-1-2", "15:04:05"}
Functions ¶
func AddMonth ¶ added in v1.0.27
AddMonth2019-12-31, 1) = 2020-01-31 AddMonth2019-12-31, 2) = 2020-02-29 AddMonth2019-12-31, 3) = 2020-03-31 AddMonth2019-12-31, 12) = 2020-12-31 AddMonth2019-12-31, 13) = 2021-01-31 AddMonth2019-12-31, 14) = 2021-02-28 AddMonth2020-03-31, -1) = 2020-02-29 AddMonth2020-03-31, -2) = 2020-01-31 AddMonth2020-03-31, -3) = 2019-12-31 AddMonth2020-03-31, -4) = 2019-11-30
func AddYear ¶ added in v1.0.27
AddYear(2020-02-29, 1) = 2021-02-28 AddYear(2020-02-29, 10) = 2030-02-28 AddYear(2020-02-29, 12) = 2032-02-29 AddYear(2020-02-29, -1) = 2019-02-28 AddYear(2020-02-29, -10) = 2010-02-28 AddYear(2020-02-29, -12) = 2008-02-29
func Atod ¶ added in v1.0.17
Atod convert string to time.Duration. if not found or convert error, returns the first non-zero value from defs.
func HumanDuration ¶ added in v1.0.27
HumanDuration returns a string representing the duration in the form "3d23h3m5s". Leading zero units are omitted. As a special case, durations less than one second format use a smaller unit (milli-, micro-, or nanoseconds) to ensure that the leading digit is non-zero. The zero duration formats as 0s.
func IsLeapYear ¶ added in v1.0.27
func LocalFormat ¶ added in v1.2.3
func LocalFormatDate ¶ added in v1.2.3
func LocalFormatDateTime ¶ added in v1.2.3
func LocalFormatTime ¶ added in v1.2.3
func ParseDuration ¶ added in v1.2.4
ParseDuration parses a duration string. A duration string is a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as "300ms", "-1.5h" or "2h45m". Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h", "d".
func ParseInLocation ¶ added in v1.0.26
func TruncateHours ¶ added in v1.0.26
TruncateHours tuncate hours for time t. Returns the time (local: yyyy-MM-dd 00:00:00).
func TruncateMinutes ¶ added in v1.0.26
TruncateMinutes tuncate minutes for time t. Returns the time (yyyy-MM-dd hh:00:00).
Types ¶
type HHMM ¶
type HHMM int
HHMM HH:MM (Minutes)
func (HHMM) MarshalJSON ¶
func (*HHMM) UnmarshalJSON ¶
type MMSS ¶
type MMSS int
MMSS MM:SS (Seconds)