[phylo] add 'Second' time unit

parent 01091149
......@@ -177,6 +177,7 @@ timeToLabel config = case (timeUnit config) of
Day p s f -> ("time_days" <> "_" <> (show p) <> "_" <> (show s) <> "_" <> (show f))
Hour _p _s _f -> panicTrace "hours not implemented"
Minute _p _s _f -> panicTrace "minutes not implemented"
Second _p _s _f -> panicTrace "seconds not implemented"
seaToLabel :: PhyloConfig -> [Char]
......
......@@ -143,6 +143,10 @@ data TimeUnit =
{ _minute_period :: Int
, _minute_step :: Int
, _minute_matchingFrame :: Int }
| Second
{ _second_period :: Int
, _second_step :: Int
, _second_matchingFrame :: Int }
deriving (Show,Generic,Eq,NFData,ToExpr)
instance ToSchema TimeUnit where
......
......@@ -210,7 +210,10 @@ toHours :: UTCTimeR -> Date
toHours utcTimeR = toMinutes utcTimeR `div` 60
toMinutes :: UTCTimeR -> Date
toMinutes utcTimeR = floor diffSeconds `div` 60
toMinutes utcTimeR = toSeconds utcTimeR `div` 60
toSeconds :: UTCTimeR -> Date
toSeconds utcTimeR = floor diffSeconds
where
diffSeconds = diffUTCTime (toUTCTime utcTimeR) (toUTCTime defUTCTimeR)
......@@ -223,6 +226,7 @@ toPhyloDate utcTimeR@(UTCTimeR { .. }) tu = case tu of
Day {} -> toDays (Prelude.toInteger year) month day
Hour {} -> toHours utcTimeR
Minute {} -> toMinutes utcTimeR
Second {} -> toSeconds utcTimeR
_ -> panic "[G.C.V.P.API.Tools] toPhyloDate"
toPhyloDate' :: UTCTimeR -> TimeUnit -> Text
......
......@@ -177,6 +177,7 @@ getTimeScale p = case timeUnit $ getConfig p of
Day {} -> "day"
Hour {} -> "hour"
Minute {} -> "minute"
Second {} -> "second"
-- | Get a regular & ascendante timeScale from a given list of dates
......@@ -195,6 +196,7 @@ getTimeStep time = case time of
Day { .. } -> _day_step
Hour { .. } -> _hour_step
Minute { .. } -> _minute_step
Second { .. } -> _second_step
getTimePeriod :: TimeUnit -> Int
getTimePeriod time = case time of
......@@ -205,6 +207,7 @@ getTimePeriod time = case time of
Day { .. } -> _day_period
Hour { .. } -> _hour_period
Minute { .. } -> _minute_period
Second { .. } -> _second_period
getTimeFrame :: TimeUnit -> Int
getTimeFrame time = case time of
......@@ -215,6 +218,7 @@ getTimeFrame time = case time of
Day { .. } -> _day_matchingFrame
Hour { .. } -> _hour_matchingFrame
Minute { .. } -> _minute_matchingFrame
Second { .. } -> _second_matchingFrame
-------------
-- | Fis | --
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment