chore(date): revert time range formatter
This commit is contained in:
parent
b069282d0a
commit
84481048df
@ -333,29 +333,22 @@ formatTimeRange' :: ( HasLocalTime t, HasLocalTime t'
|
||||
-> t -- ^ Start
|
||||
-> Maybe t' -- ^ End
|
||||
-> m Text
|
||||
formatTimeRange' cont proj startT Nothing = cont proj startT
|
||||
formatTimeRange' cont proj startT (Just endT) = do
|
||||
-- In order to abbreviate common same month time ranges, e.g. 24--26.12.23 on must take into account all DateFormatString, as some have the day on the end or feature a weekday
|
||||
formatTimeRange' cont proj startT endT = do
|
||||
startT' <- cont proj startT
|
||||
let
|
||||
locDayStart = localDay $ toLocalTime startT
|
||||
locDayEnd = localDay $ toLocalTime endT
|
||||
(yearStart, monthStart, dayStart) = toGregorian locDayStart
|
||||
(yearEnd , monthEnd , dayEnd ) = toGregorian locDayEnd
|
||||
endProj = (/\ proj) $ if
|
||||
| locDayStart == locDayEnd
|
||||
-> SelFormatTime
|
||||
| Just endT' <- endT
|
||||
, ((==) `on` localDay) (toLocalTime startT) (toLocalTime endT')
|
||||
-> SelFormatTime
|
||||
| otherwise
|
||||
-> SelFormatDateTime
|
||||
startT' <- cont proj startT
|
||||
endT' <- cont endProj endT
|
||||
return $ if
|
||||
| SelFormatDate == endProj
|
||||
, yearStart == yearEnd
|
||||
, monthStart == monthEnd
|
||||
-> if dayStart == dayEnd
|
||||
then startT'
|
||||
else [st|#{dayStart} - #{endT'}|] -- does not work all date/time format strings!
|
||||
| otherwise
|
||||
-> [st|#{startT'} - #{endT'}|]
|
||||
-> SelFormatDateTime
|
||||
endT' <- for endT $ cont endProj
|
||||
|
||||
return $ case endT' of
|
||||
Nothing -> startT'
|
||||
Just endT'' -> [st|#{startT'} – #{endT''}|]
|
||||
|
||||
|
||||
formatTimeRange :: ( HasLocalTime t, HasLocalTime t'
|
||||
, MonadHandler m
|
||||
|
||||
Loading…
Reference in New Issue
Block a user