Properly return the zero time for invalid timestamps
This commit is contained in:
parent
a32749ff89
commit
701893ebbd
@ -15,11 +15,11 @@ func GetStartTime(ctx context.Context, unit string, opts Options) (time.Time, er
|
|||||||
value, err := Show(ctx, unit, properties.ExecMainStartTimestamp, opts)
|
value, err := Show(ctx, unit, properties.ExecMainStartTimestamp, opts)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return time.Unix(0, 0), err
|
return time.Time{}, err
|
||||||
}
|
}
|
||||||
// ExecMainStartTimestamp returns an empty string if the unit is not running
|
// ExecMainStartTimestamp returns an empty string if the unit is not running
|
||||||
if value == "" {
|
if value == "" {
|
||||||
return time.Unix(0, 0), ErrUnitNotActive
|
return time.Time{}, ErrUnitNotActive
|
||||||
}
|
}
|
||||||
return time.Parse(dateFormat, value)
|
return time.Parse(dateFormat, value)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user