/SwiftDuration

duration parser ported from https://github.com/domchristie/juration

Primary LanguageSwift

SwiftDuration

tests

Parse durations from natural language into seconds

Duration.parse("10 days, 6 minutes and 5 seconds")
---
864365
units
second, sec, s
minute, min, m
hour, hr, h
day, dy, d
week, wk, w
month, mon, mo, mth
year, yr, y

Convert seconds back to natual language

Duration.stringify(83)
---
"1 minute 23 seconds"
Duration.stringify(83, format: .short)
long short micro crono
second sec s :
minute min m :
hour hr h :
day day d :
week wk w :
month mon mth :
year yr y :
Duration.stringify(83, joiner: .pretty)
---
"1 minute and 23 seconds"
Duration.stringify(864365, joiner: .pretty)
---
"10 days, 6 minutes and 5 seconds"