Sha256: 628e8b538074e138db57ce5e7691cdc65276fa935f067e48fdfc810a74b8ae00
Contents?: true
Size: 586 Bytes
Versions: 270
Compression:
Stored size: 586 Bytes
Contents
module Clock open System type Clock = { hours: int; minutes: int } let modulo x y = (int)(((x % y) + y) % y) let mkClock hours minutes = let totalMinutes = hours * 60 + minutes let normalizedHours = modulo ((double)totalMinutes / 60.0) 24.0 let normalizedMinutes = modulo ((double)minutes) 60.0 { hours = normalizedHours; minutes = normalizedMinutes } let add minutes clock = mkClock clock.hours (clock.minutes + minutes) let subtract minutes clock = mkClock clock.hours (clock.minutes - minutes) let display clock = sprintf "%02i:%02i" clock.hours clock.minutes
Version data entries
270 entries across 270 versions & 1 rubygems