fix: Accept Systemd time span syntax when decoding time.Duration fields besides Go native format #18

Merged
onlyati merged 3 commits from fix/systemd-duration-parsing into main 2026-09-14 19:35:26 +00:00
Owner

Resolve #17

Resolve #17
setFieldValue delegated straight to time.ParseDuration, which rejects
common systemd.time(7) syntax such as a bare number of seconds ("30"),
the "min" unit, and space-separated compound spans ("1min 30s"). Add a
parseSystemdDuration helper that understands systemd's own unit
spellings and use it instead.
parseSystemdDuration's own grammar could not parse concatenated
compound spans like "1h30m" since it splits components on whitespace.
Try time.ParseDuration first so plain and compound Go-style durations
still work, falling back to the systemd.time(7) parser only when Go's
parser rejects the value (bare seconds, "min"/"sec" spellings, or
space-separated compounds).
fix: Linting
All checks were successful
ci/woodpecker/pr/pr_check Pipeline was successful
ci/woodpecker/pr/ci Pipeline was successful
a31262def1
onlyati changed title from fix/systemd-duration-parsing to fix: Accept Systemd time span syntax when decoding time.Duration fields besides Go native format 2026-09-14 19:33:28 +00:00
onlyati deleted branch fix/systemd-duration-parsing 2026-09-14 19:35:26 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
pandora/systemd-file.gopack!18
No description provided.