@@ -58,15 +58,15 @@ func UnitToDuration(unit string) (time.Duration, error) {
58
58
return 0 , fmt .Errorf ("Unit %s did not match" , unit )
59
59
}
60
60
61
- // ToDuration converts a systemd relative time string into time.Duration
62
- func ToDuration (raw string ) (time.Duration , error ) {
61
+ // ParseDuration converts a systemd relative time string into time.Duration
62
+ func ParseDuration (raw string ) (time.Duration , error ) {
63
63
re , err := regexp .Compile (`^\s*-?\s*(\d+\s*[a-z]+)` )
64
64
if err != nil {
65
65
return 0 , err
66
66
}
67
67
68
68
if ! re .MatchString (raw ) {
69
- return 0 , fmt .Errorf ("ToDuration : incorrect format for raw input %s" , raw )
69
+ return 0 , fmt .Errorf ("ParseDuration : incorrect format for raw input %s" , raw )
70
70
}
71
71
72
72
reNegative , err := regexp .Compile (`^\s*-.*` )
@@ -119,7 +119,7 @@ func ToDuration(raw string) (time.Duration, error) {
119
119
120
120
// AdjustTime takes a systemd time adjustment string and uses it to modify a time.Time
121
121
func AdjustTime (original time.Time , adjustment string ) (time.Time , error ) {
122
- duration , err := ToDuration (adjustment )
122
+ duration , err := ParseDuration (adjustment )
123
123
if err != nil {
124
124
return time.Time {}, err
125
125
}
0 commit comments