Documentation ¶
Index ¶
Constants ¶
View Source
const ( // Regex used to match the duration Regex = "^((\\+|\\-))?([1-9][0-9]*)\\s?(ms|milliseconds?|s|seconds?|m|minutes?|h|hours?|d|days?|w|weeks?)$" // Day represents 24 hours durations Day = time.Hour * 24 // Week represents 7 days Week = Day * 7 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Parser ¶
type Parser struct{}
Parser is the service that will provide the package functionality
func (*Parser) Duration ¶
Duration returns a time.Duration object with the equivalent duration representation of the input
The input string must contain a time unit and a signed multiplier ('+' sign by default if omitted)
The accepted time unit are:
- `ms`, `millisecond` or `milliseconds`
- `s`, `second` or `seconds`
- `m`, `minute` or `minutes`
- `h`, `hour` or `hours`
- `d`, `day` or `days`
- `w`, `week` or `weeks`
Examples:
- `10s`: after ten seconds
- `+1 minute`: after one minute
- `2 hours`: after two hours
- `-1 day`: minus one day
- `-2w`: minus two weeks
Click to show internal directories.
Click to hide internal directories.