2020-04-03 23:11:33 +00:00
|
|
|
package utils
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"regexp"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
2020-04-20 21:03:38 +00:00
|
|
|
// ErrTimeoutReached error thrown when a timeout is reached.
|
2020-04-03 23:11:33 +00:00
|
|
|
var ErrTimeoutReached = errors.New("timeout reached")
|
|
|
|
var parseDurationRegexp = regexp.MustCompile(`^(?P<Duration>[1-9]\d*?)(?P<Unit>[smhdwMy])?$`)
|
|
|
|
|
2020-05-02 05:06:39 +00:00
|
|
|
// Hour is an int based representation of the time unit.
|
2020-04-03 23:11:33 +00:00
|
|
|
const Hour = time.Minute * 60
|
2020-04-20 21:03:38 +00:00
|
|
|
|
2020-05-02 05:06:39 +00:00
|
|
|
// Day is an int based representation of the time unit.
|
2020-04-03 23:11:33 +00:00
|
|
|
const Day = Hour * 24
|
2020-04-20 21:03:38 +00:00
|
|
|
|
2020-05-02 05:06:39 +00:00
|
|
|
// Week is an int based representation of the time unit.
|
2020-04-03 23:11:33 +00:00
|
|
|
const Week = Day * 7
|
2020-04-20 21:03:38 +00:00
|
|
|
|
2020-05-02 05:06:39 +00:00
|
|
|
// Year is an int based representation of the time unit.
|
2020-04-03 23:11:33 +00:00
|
|
|
const Year = Day * 365
|
2020-04-20 21:03:38 +00:00
|
|
|
|
2020-05-02 05:06:39 +00:00
|
|
|
// Month is an int based representation of the time unit.
|
2020-04-03 23:11:33 +00:00
|
|
|
const Month = Year / 12
|
2020-05-02 16:20:40 +00:00
|
|
|
|
2020-05-04 19:39:25 +00:00
|
|
|
// RFC3339Zero is the default value for time.Time.Unix().
|
|
|
|
const RFC3339Zero = int64(-62135596800)
|
|
|
|
|
2020-05-02 16:20:40 +00:00
|
|
|
const testStringInput = "abcdefghijkl"
|