@@ -229,22 +229,25 @@ time_to_seconds(t::Number) =
229229"""
230230 time_to_seconds(s::String)
231231
232- Convert a string representing a time to seconds. Supported units: seconds, minutes, hours, days as
233- `s`, `secs`, `m`, `mins`, `h`, `hours`, `d`, `days`.
232+ Convert a string representing a time to seconds. Supported units: seconds, minutes, hours, days, weeks as
233+ `s`, `secs`, `m`, `mins`, `h`, `hours`, `d`, `days`, `weeks` .
234234"""
235235function time_to_seconds (s:: String )
236236 s == " Inf" && return Inf
237237 # match a number followed by one of the supported units of time
238- m = match (r" ^(\d +(?:\.\d +)?)(s|secs|m|mins|h|hours|d|days)$" , s)
238+ m = match (r" ^(\d +(?:\.\d +)?)(s|secs|m|mins|h|hours|d|days|weeks )$" , s)
239239 isnothing (m) &&
240- error (" Bad format for flag $s . Examples: `10secs`, `20mins`, `30hours`, `40days`" )
240+ error (
241+ " Bad format for flag $s . Examples: `10secs`, `20mins`, `30hours`, `40days`, `50weeks`" ,
242+ )
241243 value = parse (Float64, m. captures[1 ])
242244 unit = m. captures[2 ]
243245 factor_groups = Dict (
244246 [" s" , " secs" ] => 1 ,
245247 [" m" , " mins" ] => 60 ,
246248 [" h" , " hours" ] => 3600 ,
247249 [" d" , " days" ] => 86400 ,
250+ [" weeks" ] => 604800 ,
248251 )
249252 factors = Dict (unit => val for (units, val) in factor_groups for unit in units)
250253 return value * factors[unit]
0 commit comments