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