{-# OPTIONS -fno-warn-orphans -fno-warn-unused-imports #-}#include "HsConfigure.h"-- #hidemoduleData.Time.LocalTime.LocalTime(-- * Local TimeLocalTime (..),-- converting UTC and UT1 times to LocalTimeutcToLocalTime ,localTimeToUTC ,ut1ToLocalTime ,localTimeToUT1 ,ZonedTime (..),utcToZonedTime ,zonedTimeToUTC ,getZonedTime ,utcToLocalZonedTime )whereimportData.Time.LocalTime.TimeOfDay importData.Time.LocalTime.TimeZone importData.Time.Calendar.Days importData.Time.Calendar.Gregorian importData.Time.Clock.Scale importData.Time.Clock.UTCDiff importData.Time.Clock.UTC importData.Time.Clock.POSIX importControl.DeepSeqimportData.Typeable#if LANGUAGE_Rank2TypesimportData.Data#endif-- | A simple day and time aggregate, where the day is of the specified parameter,-- and the time is a TimeOfDay.-- Conversion of this (as local civil time) to UTC depends on the time zone.-- Conversion of this (as local mean time) to UT1 depends on the longitude.dataLocalTime =LocalTime {localDay ::Day ,localTimeOfDay ::TimeOfDay }deriving(Eq,Ord#if LANGUAGE_DeriveDataTypeable#if LANGUAGE_Rank2Types#if HAS_DataPico,Data,Typeable#endif#endif#endif)instanceNFDataLocalTime wherernf (LocalTime d t )=d `deepseq`t `deepseq`()instanceShowLocalTime whereshow (LocalTime d t )=(showGregorian d )++" "++(showt )-- | show a UTC time in a given time zone as a LocalTimeutcToLocalTime::TimeZone ->UTCTime ->LocalTime utcToLocalTime tz (UTCTime day dt )=LocalTime (addDays i day )tod where(i ,tod )=utcToLocalTimeOfDay tz (timeToTimeOfDay dt )-- | find out what UTC time a given LocalTime in a given time zone islocalTimeToUTC::TimeZone ->LocalTime ->UTCTime localTimeToUTC tz (LocalTime day tod )=UTCTime (addDays i day )(timeOfDayToTime todUTC )where(i ,todUTC )=localToUTCTimeOfDay tz tod -- | 1st arg is observation meridian in degrees, positive is Eastut1ToLocalTime::Rational->UniversalTime ->LocalTime ut1ToLocalTime long (ModJulianDate date )=LocalTime (ModifiedJulianDay localMJD )(dayFractionToTimeOfDay localToDOffset )wherelocalTime =date +long /360::RationallocalMJD =floorlocalTime localToDOffset =localTime -(fromIntegrallocalMJD )-- | 1st arg is observation meridian in degrees, positive is EastlocalTimeToUT1::Rational->LocalTime ->UniversalTime localTimeToUT1 long (LocalTime (ModifiedJulianDay localMJD )tod )=ModJulianDate ((fromIntegrallocalMJD )+(timeOfDayToDayFraction tod )-(long /360))-- orphan instanceinstanceShowUniversalTime whereshow t =show(ut1ToLocalTime 0t )-- | A local time together with a TimeZone.dataZonedTime =ZonedTime {zonedTimeToLocalTime ::LocalTime ,zonedTimeZone ::TimeZone }#if LANGUAGE_DeriveDataTypeable#if LANGUAGE_Rank2Types#if HAS_DataPicoderiving(Data,Typeable)#endif#endif#endifinstanceNFDataZonedTime wherernf (ZonedTime lt z )=lt `deepseq`z `deepseq`()utcToZonedTime::TimeZone ->UTCTime ->ZonedTime utcToZonedTime zone time =ZonedTime (utcToLocalTime zone time )zone zonedTimeToUTC::ZonedTime ->UTCTime zonedTimeToUTC (ZonedTime t zone )=localTimeToUTC zone t instanceShowZonedTime whereshow (ZonedTime t zone )=showt ++" "++showzone -- orphan instanceinstanceShowUTCTime whereshow t =show(utcToZonedTime utc t )getZonedTime::IOZonedTime getZonedTime =dot <-getCurrentTime zone <-getTimeZone t return(utcToZonedTime zone t )-- |utcToLocalZonedTime::UTCTime ->IOZonedTime utcToLocalZonedTime t =dozone <-getTimeZone t return(utcToZonedTime zone t )