Skip to content
Snippets Groups Projects
Commit 96e9a932 authored by Ashley Yakeley's avatar Ashley Yakeley
Browse files

new functions (aliases) pastMidnight & sinceMidnight (#117)

parent d856620a
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,7 @@
- parsing: fix %_Q %-Q %_q %-q
- formatting: fix %3ES %3Es
- change internal members of ParseTime to allow newtype-deriving
- new functions (aliases) pastMidnight & sinceMidnight
## [1.9.3]
- documentation fixes
......
......@@ -12,7 +12,9 @@ module Data.Time.LocalTime.Internal.TimeOfDay
, utcToLocalTimeOfDay
, localToUTCTimeOfDay
, timeToTimeOfDay
, pastMidnight
, timeOfDayToTime
, sinceMidnight
, dayFractionToTimeOfDay
, timeOfDayToDayFraction
) where
......@@ -100,10 +102,18 @@ timeToTimeOfDay dt = TimeOfDay (fromInteger h) (fromInteger m) s
m = mod' m' 60
h = div' m' 60
-- | Same as 'timeToTimeOfDay'.
pastMidnight :: DiffTime -> TimeOfDay
pastMidnight = timeToTimeOfDay
-- | Get the time since midnight for a given time of day.
timeOfDayToTime :: TimeOfDay -> DiffTime
timeOfDayToTime (TimeOfDay h m s) = ((fromIntegral h) * 60 + (fromIntegral m)) * 60 + (realToFrac s)
-- | Same as 'timeOfDayToTime'.
sinceMidnight :: TimeOfDay -> DiffTime
sinceMidnight = timeOfDayToTime
-- | Get the time of day given the fraction of a day since midnight.
dayFractionToTimeOfDay :: Rational -> TimeOfDay
dayFractionToTimeOfDay df = timeToTimeOfDay (realToFrac (df * 86400))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment