kbtime

package
v5.4.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2020 License: BSD-3-Clause, BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddLongDuration

func AddLongDuration(tval time.Time, duration string) (ret time.Time, err error)

AddLongDuration parses time duration from `duration` argument and adds to time in `now`, returning the resulting time. The duration format is similar to `time` package duration format, with the following changes: - additional duration units are supported:

  • 'D' for days,
  • 'M' for months,
  • 'Y' for years,
  • fractional numbers are *not* supported,
  • negative numbers are *not* supported,
  • whitespace at the beginning and end of duration string is ignored,
  • optionally there can be one whitespace character between the number and unit.

Long durations are handled using Time.AddDate function, which works by adding given number of years, months, and days to tval. It normalizes its result, for example, adding one month to October 31 yields December 1, the normalized form for November 31.

Examples:

`AddLongDuration(time.Now(), "1000 Y")`
`AddLongDuration(time.Now(), "7 D")`
`AddLongDuration(then, "1 M")`

Types

This section is empty.

Jump to

Keyboard shortcuts

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