{-# OPTIONS -fno-warn-unused-imports #-}{-# LANGUAGE ForeignFunctionInterface #-}#include "HsConfigure.h"-- #hidemoduleData.Time.LocalTime.TimeZone(-- * Time zonesTimeZone(..),timeZoneOffsetString,timeZoneOffsetString',minutesToTimeZone,hoursToTimeZone,utc,-- getting the locale time zonegetTimeZone,getCurrentTimeZone)where--import System.Time.Calendar.FormatimportData.Time.Calendar.PrivateimportData.Time.ClockimportData.Time.Clock.POSIXimportForeignimportForeign.CimportData.Typeable#if LANGUAGE_Rank2TypesimportData.Data#endif-- | A TimeZone is a whole number of minutes offset from UTC, together with a name and a \"just for summer\" flag.dataTimeZone=TimeZone{-- | The number of minutes offset from UTC. Positive means local time will be later in the day than UTC.timeZoneMinutes::Int,-- | Is this time zone just persisting for the summer?timeZoneSummerOnly::Bool,-- | The name of the zone, typically a three- or four-letter acronym.timeZoneName::String}deriving(Eq,Ord#if LANGUAGE_DeriveDataTypeable#if LANGUAGE_Rank2Types,Data#endif#endif)instanceTypeableTimeZonewheretypeOf_=mkTyConApp(mkTyCon"Data.Time.LocalTime.TimeZone.TimeZone")[]-- | Create a nameless non-summer timezone for this number of minutesminutesToTimeZone::Int->TimeZoneminutesToTimeZonem=TimeZonemFalse""-- | Create a nameless non-summer timezone for this number of hourshoursToTimeZone::Int->TimeZonehoursToTimeZonei=minutesToTimeZone(60*i)showT::NumericPadOption->Int->StringshowToptt=show4opt((divt60)*100+(modt60))-- | Text representing the offset of this timezone, such as \"-0800\" or \"+0400\" (like %z in formatTime), with arbitrary paddingtimeZoneOffsetString'::NumericPadOption->TimeZone->StringtimeZoneOffsetString'opt(TimeZonet__)|t<0='-':(showTopt(negatet))timeZoneOffsetString'opt(TimeZonet__)='+':(showToptt)-- | Text representing the offset of this timezone, such as \"-0800\" or \"+0400\" (like %z in formatTime)timeZoneOffsetString::TimeZone->StringtimeZoneOffsetString=timeZoneOffsetString'(Just'0')instanceShowTimeZonewhereshowzone@(TimeZone__"")=timeZoneOffsetStringzoneshow(TimeZone__name)=name-- | The UTC time zoneutc::TimeZoneutc=TimeZone0False"UTC"{-# CFILES cbits/HsTime.c #-}foreignimportccallunsafe"HsTime.h get_current_timezone_seconds"get_current_timezone_seconds::CTime->PtrCInt->PtrCString->IOCLongposixToCTime::POSIXTime->CTimeposixToCTime=fromInteger.floor-- | Get the local time-zone for a given time (varying as per summertime adjustments)getTimeZone::UTCTime->IOTimeZonegetTimeZonetime=with0(\pdst->withnullPtr(\pcname->dosecs<-get_current_timezone_seconds(posixToCTime(utcTimeToPOSIXSecondstime))pdstpcnamecasesecsof0x80000000->fail"localtime_r failed"_->dodst<-peekpdstcname<-peekpcnamename<-peekCStringcnamereturn(TimeZone(div(fromIntegralsecs)60)(dst==1)name)))-- | Get the current time-zonegetCurrentTimeZone::IOTimeZonegetCurrentTimeZone=getCurrentTime>>=getTimeZone