Ticket #2930 (closed merge: fixed)

Opened 4 years ago

Last modified 4 years ago

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

Changed 4 years ago by igloo

  • difficulty set to Unknown
  • milestone set to 6.10.2

Thanks for the report.

This bug is also mentioned in a comment in System/Time.hsc.

Changed 4 years ago by simonmar

  • owner set to simonmar

I'll do this.

Changed 4 years ago by simonmar

  • owner changed from simonmar to igloo
  • type changed from bug to merge

Fixed:

Wed Mar 11 10:30:48 GMT 2009  Simon Marlow <marlowsd@gmail.com>
  * FIX #2930 (formatCalaendarTime's %s wasn't working properly)

Changed 4 years ago by igloo

  • status changed from new to closed
  • resolution set to fixed

Merged.

Note: See TracTickets for help on using tickets.