Ticket #2930 (closed merge: fixed)
System.Time.formatCalendarTime: %s isn't the number of seconds since the Epoch
| Reported by: | wferi | Owned by: | igloo |
|---|---|---|---|
| Priority: | normal | Milestone: | 6.10.2 |
| Component: | libraries/old-time | Version: | 6.8.2 |
| Keywords: | Cc: | ||
| Operating System: | Linux | Architecture: | x86 |
| Type of failure: | Difficulty: | Unknown | |
| Test Case: | Blocked By: | ||
| Blocking: | Related Tickets: |
Description
formatCalendarTime references strftime(3), and man strftime says that %s is "the number of seconds since the Epoch, that is, since 1970-01-01 00:00:00 UTC." However, under GHC 6.8.2 it is restricted to the 00-59 range, as the following demonstrates.
epoch.hs is the following:
import System.Time main = putStrLn $ formatCalendarTime undefined "%Y-%m-%d %T (%s)" (toUTCTime $ TOD 62 0)
And now:
$ runghc epoch.hs 1970-01-01 00:01:02 (02) $ date --utc -d @62 +"%Y-%m-%d %T (%s)" 1970-01-01 00:01:02 (62)
I think GNU date is right, System.Time is wrong.
Change History
Note: See
TracTickets for help on using
tickets.
