...
 
Commits (2)
definition module iTasks.Extensions.DateTime.Gast
from iTasks.Extensions.DateTime import :: Time
from iTasks.Extensions.DateTime import :: Date, :: Time, :: DateTime
from Gast import generic genShow, generic ggen, :: GenState
derive ggen Time
derive genShow Time
derive ggen Date, Time, DateTime
derive genShow Date, Time, DateTime
implementation module iTasks.Extensions.DateTime.Gast
import StdEnv, Gast, iTasks.Extensions.DateTime
import StdEnv, Gast, Data.List, Data.Functor, iTasks.Extensions.DateTime
ggen{|Time|} _ = [{Time| hour = h, min = m, sec = s} \\ (h,m,s) <- diag3 [0,23:[1..22]] [0,59:[1..58]] [0,59,60:[1..58]]]
derive genShow Time
// Years can be negative (BC), the range of +/- 3000 years is chosen more or less arbitrarily,
// but should include most years used in realistic programs.
ggen{|Date|} _ =
[{Date| year = y, mon = m, day = d} \\ (y,m,d) <- diag3 [0,-3000, 3000:[-2999..2999]] [1,12:[2..11]] [1,31:[2..30]]]
ggen{|Time|} _ =
[{Time| hour = h, min = m, sec = s} \\ (h,m,s) <- diag3 [0,23:[1..22]] [0,59:[1..58]] [0,59,60:[1..58]]]
ggen{|DateTime|} st = (uncurry toDateTime) <$> ggen{|*|} st
derive genShow Date, Time, DateTime