1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-26 18:21:01 +00:00

feat(config): time interval parser

Simplifies handling of time intervals in config values.
This commit is contained in:
gudvinr 2025-08-18 23:10:18 +03:00 committed by Frédéric Guillot
parent 83254a1f26
commit 03021af53c

View file

@ -358,6 +358,20 @@ func parseBytes(value string, fallback []byte) []byte {
return []byte(value)
}
// parseInterval converts an integer "value" to [time.Duration] using "unit" as multiplier.
func parseInterval(value string, unit time.Duration, fallback time.Duration) time.Duration {
if value == "" {
return fallback
}
v, err := strconv.Atoi(value)
if err != nil {
return fallback
}
return time.Duration(v) * unit
}
func readSecretFile(filename, fallback string) string {
data, err := os.ReadFile(filename)
if err != nil {