Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
time
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Rinat Striungis
time
Commits
96e9a932
Commit
96e9a932
authored
5 years ago
by
Ashley Yakeley
Browse files
Options
Downloads
Patches
Plain Diff
new functions (aliases) pastMidnight & sinceMidnight (#117)
parent
d856620a
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
changelog.md
+1
-0
1 addition, 0 deletions
changelog.md
lib/Data/Time/LocalTime/Internal/TimeOfDay.hs
+10
-0
10 additions, 0 deletions
lib/Data/Time/LocalTime/Internal/TimeOfDay.hs
with
11 additions
and
0 deletions
changelog.md
+
1
−
0
View file @
96e9a932
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
lib/Data/Time/LocalTime/Internal/TimeOfDay.hs
+
10
−
0
View file @
96e9a932
...
...
@@ -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
))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment