[phylo] add 'Second' time unit

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