diff --git a/src/Handler/Term.hs b/src/Handler/Term.hs
index d6047f29f..345f0d882 100644
--- a/src/Handler/Term.hs
+++ b/src/Handler/Term.hs
@@ -77,20 +77,18 @@ getTermShowR = do
-> cell $ formatTime SelFormatDate termEnd >>= toWidget
, sortable Nothing (i18nCell MsgTermHolidays) $ \(Entity _ Term{..},_, _)
-> cell $ do
- let termHolidays' = groupHolidays termHolidays
- [whamlet|
- $newline never
-
- $forall holiday <- termHolidays'
- $case holiday
- $of Left singleHoliday
- - ^{formatTimeW SelFormatDate singleHoliday}
- $of Right (startD, endD)
-
-
- ^{formatTimeW SelFormatDate startD}
- –
- ^{formatTimeW SelFormatDate endD}
- |]
+ let termHolidays' = groupHolidays termHolidays
+ [whamlet|
+ $newline never
+
+ $forall holiday <- termHolidays'
+ -
+ $case holiday
+ $of Left singleHoliday
+ ^{formatTimeW SelFormatDate singleHoliday}
+ $of Right (startD, endD)
+ ^{formatTimeRangeW SelFormatDate startD (Just endD)}
+ |]
]
dbtSorting = Map.fromList
[ ( "start"
diff --git a/src/Handler/Utils/DateTime.hs b/src/Handler/Utils/DateTime.hs
index c54cd7854..5cf0030fa 100644
--- a/src/Handler/Utils/DateTime.hs
+++ b/src/Handler/Utils/DateTime.hs
@@ -333,21 +333,29 @@ formatTimeRange' :: ( HasLocalTime t, HasLocalTime t'
-> t -- ^ Start
-> Maybe t' -- ^ End
-> m Text
-formatTimeRange' cont proj startT endT = do
- startT' <- cont proj startT
+formatTimeRange' cont proj startT Nothing = cont proj startT
+formatTimeRange' cont proj startT (Just endT) = do
let
+ locDayStart = localDay $ toLocalTime startT
+ locDayEnd = localDay $ toLocalTime endT
+ (yearStart, monthStart, dayStart) = toGregorian locDayStart
+ (yearEnd , monthEnd , dayEnd ) = toGregorian locDayEnd
endProj = (/\ proj) $ if
- | Just endT' <- endT
- , ((==) `on` localDay) (toLocalTime startT) (toLocalTime endT')
- -> SelFormatTime
+ | locDayStart == locDayEnd
+ -> SelFormatTime
| otherwise
- -> SelFormatDateTime
- endT' <- for endT $ cont endProj
-
- return $ case endT' of
- Nothing -> startT'
- Just endT'' -> [st|#{startT'} – #{endT''}|]
-
+ -> 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'}|]
formatTimeRange :: ( HasLocalTime t, HasLocalTime t'
, MonadHandler m