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
|
-> t -- ^ Start
|
||||||
-> Maybe t' -- ^ End
|
-> Maybe t' -- ^ End
|
||||||
-> m Text
|
-> m Text
|
||||||
formatTimeRange' cont proj startT Nothing = cont proj startT
|
-- 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 (Just endT) = do
|
formatTimeRange' cont proj startT endT = do
|
||||||
|
startT' <- cont proj startT
|
||||||
let
|
let
|
||||||
locDayStart = localDay $ toLocalTime startT
|
|
||||||
locDayEnd = localDay $ toLocalTime endT
|
|
||||||
(yearStart, monthStart, dayStart) = toGregorian locDayStart
|
|
||||||
(yearEnd , monthEnd , dayEnd ) = toGregorian locDayEnd
|
|
||||||
endProj = (/\ proj) $ if
|
endProj = (/\ proj) $ if
|
||||||
| locDayStart == locDayEnd
|
| Just endT' <- endT
|
||||||
-> SelFormatTime
|
, ((==) `on` localDay) (toLocalTime startT) (toLocalTime endT')
|
||||||
|
-> SelFormatTime
|
||||||
| otherwise
|
| otherwise
|
||||||
-> SelFormatDateTime
|
-> SelFormatDateTime
|
||||||
startT' <- cont proj startT
|
endT' <- for endT $ cont endProj
|
||||||
endT' <- cont endProj endT
|
|
||||||
return $ if
|
return $ case endT' of
|
||||||
| SelFormatDate == endProj
|
Nothing -> startT'
|
||||||
, yearStart == yearEnd
|
Just endT'' -> [st|#{startT'} – #{endT''}|]
|
||||||
, monthStart == monthEnd
|
|
||||||
-> if dayStart == dayEnd
|
|
||||||
then startT'
|
|
||||||
else [st|#{dayStart} - #{endT'}|] -- does not work all date/time format strings!
|
|
||||||
| otherwise
|
|
||||||
-> [st|#{startT'} - #{endT'}|]
|
|
||||||
|
|
||||||
formatTimeRange :: ( HasLocalTime t, HasLocalTime t'
|
formatTimeRange :: ( HasLocalTime t, HasLocalTime t'
|
||||||
, MonadHandler m
|
, MonadHandler m
|
||||||
|
|||||||
Reference in New Issue
Block a user