-formatRFC1123DateTime :: CalendarTime -> String
-formatRFC1123DateTime time
- = time `seq`
-
- id (week !! fromEnum (ctWDay time))
- ++ ", " ++
- fmtDec 2 (ctDay time)
- ++ " " ++
- id (month !! fromEnum (ctMonth time))
- ++ " " ++
- fmtDec 4 (ctYear time)
- ++ " " ++
- fmtDec 2 (ctHour time)
- ++ ":" ++
- fmtDec 2 (ctMin time)
- ++ ":" ++
- fmtDec 2 (ctSec time)
- ++ " " ++
- id (ctTZName time)
+formatRFC1123DateTime :: ZonedTime -> String
+formatRFC1123DateTime zonedTime
+ = let localTime = zonedTimeToLocalTime zonedTime
+ timeZone = zonedTimeZone zonedTime
+ (year, month, day) = toGregorian (localDay localTime)
+ (_, _, week) = toWeekDate (localDay localTime)
+ timeOfDay = localTimeOfDay localTime
+ in
+ id (weekStr !! (week - 1))
+ ++ ", " ++
+ fmtDec 2 day
+ ++ " " ++
+ id (monthStr !! (month - 1))
+ ++ " " ++
+ fmtDec 4 (fromInteger year)
+ ++ " " ++
+ fmtDec 2 (todHour timeOfDay)
+ ++ ":" ++
+ fmtDec 2 (todMin timeOfDay)
+ ++ ":" ++
+ fmtDec 2 (floor (todSec timeOfDay))
+ ++ " " ++
+ id (timeZoneName timeZone)