Skip to content

Commit

Permalink
remove trailing space
Browse files Browse the repository at this point in the history
  • Loading branch information
AshleyYakeley committed Dec 20, 2015
1 parent 05ae57a commit b31cee9
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 29 deletions.
32 changes: 16 additions & 16 deletions lib/Data/Time/Calendar/OrdinalDate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,16 @@ fromMondayStartWeek year w d = let

-- 0-based year day of first monday of the year
zbFirstMonday = (5 - toModifiedJulianDay firstDay) `mod` 7

-- 0-based week of year
zbWeek = w - 1

-- 0-based day of week
zbDay = d - 1

-- 0-based day in year
zbYearDay = zbFirstMonday + 7 * toInteger zbWeek + toInteger zbDay

in addDays zbYearDay firstDay

fromMondayStartWeekValid :: Integer -- ^ Year.
Expand All @@ -103,16 +103,16 @@ fromMondayStartWeekValid year w d = do

-- 0-based week of year
zbFirstMonday = (5 - toModifiedJulianDay firstDay) `mod` 7

-- 0-based week number
zbWeek = w - 1

-- 0-based day of week
zbDay = d' - 1

-- 0-based day in year
zbYearDay = zbFirstMonday + 7 * toInteger zbWeek + toInteger zbDay

zbYearDay' <- clipValid 0 (if isLeapYear year then 365 else 364) zbYearDay
return $ addDays zbYearDay' firstDay

Expand All @@ -131,16 +131,16 @@ fromSundayStartWeek year w d = let

-- 0-based year day of first monday of the year
zbFirstSunday = (4 - toModifiedJulianDay firstDay) `mod` 7

-- 0-based week of year
zbWeek = w - 1

-- 0-based day of week
zbDay = d

-- 0-based day in year
zbYearDay = zbFirstSunday + 7 * toInteger zbWeek + toInteger zbDay

in addDays zbYearDay firstDay

fromSundayStartWeekValid :: Integer -- ^ Year.
Expand All @@ -156,15 +156,15 @@ fromSundayStartWeekValid year w d = do

-- 0-based week of year
zbFirstSunday = (4 - toModifiedJulianDay firstDay) `mod` 7

-- 0-based week number
zbWeek = w - 1

-- 0-based day of week
zbDay = d'

-- 0-based day in year
zbYearDay = zbFirstSunday + 7 * toInteger zbWeek + toInteger zbDay

zbYearDay' <- clipValid 0 (if isLeapYear year then 365 else 364) zbYearDay
return $ addDays zbYearDay' firstDay
18 changes: 9 additions & 9 deletions lib/Data/Time/Format/Parse.hs
Original file line number Diff line number Diff line change
Expand Up @@ -329,20 +329,20 @@ instance ParseTime Day where
buildTime l = let

-- 'Nothing' indicates a parse failure,
-- while 'Just []' means no information
-- while 'Just []' means no information
f :: Char -> String -> Maybe [DayComponent]
f c x = let
ra :: (Read a) => Maybe a
ra = readMaybe x

zeroBasedListIndex :: [String] -> Maybe Int
zeroBasedListIndex ss = elemIndex (up x) $ fmap up ss

oneBasedListIndex :: [String] -> Maybe Int
oneBasedListIndex ss = do
index <- zeroBasedListIndex ss
return $ 1 + index

in case c of
-- %C: century (all but the last two digits of the year), 00 - 99
'C' -> do
Expand Down Expand Up @@ -380,7 +380,7 @@ instance ParseTime Day where
'm' -> do
raw <- ra
a <- clipValid 1 12 raw
return [YearMonth a]
return [YearMonth a]
-- %d: day of month, leading 0 as needed, 01 - 31
'd' -> do
raw <- ra
Expand Down Expand Up @@ -473,7 +473,7 @@ instance ParseTime TimeOfDay where
f t@(TimeOfDay h m s) (c,x) = let
ra :: (Read a) => Maybe a
ra = readMaybe x

getAmPm = let
upx = up x
(amStr,pmStr) = amPm l
Expand All @@ -482,7 +482,7 @@ instance ParseTime TimeOfDay where
else if upx == pmStr
then Just $ TimeOfDay (if h < 12 then h + 12 else h) m s
else Nothing

in case c of
'P' -> getAmPm
'p' -> getAmPm
Expand Down Expand Up @@ -511,7 +511,7 @@ instance ParseTime TimeOfDay where
ps <- readMaybe $ take 12 $ rpad 12 '0' $ drop 1 x
return $ TimeOfDay h m (mkPico (truncate s) ps)
_ -> Just t

in mfoldl f (Just midnight)

rpad :: Int -> a -> [a] -> [a]
Expand Down Expand Up @@ -544,7 +544,7 @@ getMilZone c = let

getKnownTimeZone :: TimeLocale -> String -> Maybe TimeZone
getKnownTimeZone locale x = find (\tz -> up x == timeZoneName tz) (knownTimeZones locale)

instance ParseTime TimeZone where
buildTime l = let
f (TimeZone _ dst name) ('z',x) | Just offset <- readTzOffset x = TimeZone offset dst name
Expand Down
2 changes: 1 addition & 1 deletion test/Test/ConvertBack.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ checkDay encodeDay decodeDay decodeDayValid day = let
then unwords [show day, "->", show st, "->", show mday']
else ""
in a ++ b

checkers :: [Day -> String]
checkers
= [ checkDay toOrdinalDate (\(y,d) -> fromOrdinalDate y d) (\(y,d) -> fromOrdinalDateValid y d)
Expand Down
6 changes: 3 additions & 3 deletions test/Test/TestTime.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ testCal :: String
testCal
= concat
-- days around 1 BCE/1 CE
[ concatMap showCal [-678950 .. -678930]
[ concatMap showCal [-678950 .. -678930]

-- days around 1000 CE
, concatMap showCal [-313710 .. -313690]
, concatMap showCal [-313710 .. -313690]

-- days around MJD zero
, concatMap showCal [-30..30]
, concatMap showCal [-30..30]
, showCal 40000
, showCal 50000

Expand Down

0 comments on commit b31cee9

Please sign in to comment.