@@ -326,13 +326,13 @@ tabFilter tabStop =
327-- | Parse a date and convert (if possible) to "YYYY-MM-DD" format. We
327-- | Parse a date and convert (if possible) to "YYYY-MM-DD" format. We
328-- limit years to the range 1601-9999 (ISO 8601 accepts greater than
328-- limit years to the range 1601-9999 (ISO 8601 accepts greater than
329−-- or equal to 1583, but MS Word only accepts dates starting 1601.
329+-- or equal to 1583, but MS Word only accepts dates starting 1601).
330normalizeDate :: String -> Maybe String
330normalizeDate :: String -> Maybe String
331−normalizeDate s = case toGregorian <$> day of
332− Just (y, _, _) | y >= 1601 && y <= 9999 ->
333− fmap (formatTime defaultTimeLocale "%F") day
331+normalizeDate s = fmap (formatTime defaultTimeLocale "%F")
335− where day = (msum $ map (\fs -> parsetimeWith fs s) formats :: Maybe Day)
332+ (msum $ map (\fs -> parsetimeWith fs s >>= rejectBadYear) formats :: Maybe Day)
333+ where rejectBadYear day = case toGregorian day of
334+ (y, _, _) | y >= 1601 && y <= 9999 -> Just day
336 parsetimeWith =
336 parsetimeWith =
337#if MIN_VERSION_time(1,5,0)
337#if MIN_VERSION_time(1,5,0)
338 parseTimeM True defaultTimeLocale
338 parseTimeM True defaultTimeLocale