Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
old-time
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Glasgow Haskell Compiler
Packages
old-time
Commits
f1e4046a
Commit
f1e4046a
authored
15 years ago
by
simonpj@microsoft.com
Browse files
Options
Downloads
Patches
Plain Diff
Commit to Double for the default in realToInteger
parent
32b8989c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
System/Time.hsc
+6
-6
6 additions, 6 deletions
System/Time.hsc
with
6 additions
and
6 deletions
System/Time.hsc
+
6
−
6
View file @
f1e4046a
...
...
@@ -233,6 +233,11 @@ noTimeDiff = TimeDiff 0 0 0 0 0 0 0
-- -----------------------------------------------------------------------------
-- | returns the current time in its internal representation.
realToInteger :: Real a => a -> Integer
realToInteger ct = round (realToFrac ct :: Double)
-- CTime, CClock, CUShort etc are in Real but not Fractional,
-- so we must convert to Double before we can round it
getClockTime :: IO ClockTime
#ifdef __HUGS__
getClockTime = do
...
...
@@ -241,7 +246,6 @@ getClockTime = do
#elif HAVE_GETTIMEOFDAY
getClockTime = do
let realToInteger = round . realToFrac :: Real a => a -> Integer
allocaBytes (#const sizeof(struct timeval)) $ \ p_timeval -> do
throwErrnoIfMinus1_ "getClockTime" $ gettimeofday p_timeval nullPtr
sec <- (#peek struct timeval,tv_sec) p_timeval :: IO CTime
...
...
@@ -250,7 +254,6 @@ getClockTime = do
#elif HAVE_FTIME
getClockTime = do
let realToInteger = round . realToFrac :: Real a => a -> Integer
allocaBytes (#const sizeof(struct timeb)) $ \ p_timeb -> do
ftime p_timeb
sec <- (#peek struct timeb,time) p_timeb :: IO CTime
...
...
@@ -260,7 +263,6 @@ getClockTime = do
#else /* use POSIX time() */
getClockTime = do
secs <- time nullPtr -- can't fail, according to POSIX
let realToInteger = round . realToFrac :: Real a => a -> Integer
return (TOD (realToInteger secs) 0)
#endif
...
...
@@ -385,7 +387,6 @@ foreign import ccall "&timezone" timezone :: Ptr CTime
gmtoff x = do
dst <- (#peek struct tm,tm_isdst) x
tz <- if dst then peek altzone else peek timezone
let realToInteger = round . realToFrac :: Real a => a -> Integer
return (-fromIntegral (realToInteger tz))
# else /* ! HAVE_DECL_ALTZONE */
...
...
@@ -567,8 +568,7 @@ toClockTime (CalendarTime year mon mday hour minute sec psec
-- result.
--
gmtoffset <- gmtoff p_tm
let realToInteger = round . realToFrac :: Real a => a -> Integer
res = realToInteger t - fromIntegral tz + fromIntegral gmtoffset
let res = realToInteger t - fromIntegral tz + fromIntegral gmtoffset
return (TOD res psec)
#endif /* ! __HUGS__ */
...
...
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