{-# OPTIONS -fno-warn-unused-imports #-}#include "HsConfigure.h"-- #hidemoduleData.Time.LocalTime.TimeOfDay(-- * Time of dayTimeOfDay(..),midnight,midday,makeTimeOfDayValid,utcToLocalTimeOfDay,localToUTCTimeOfDay,timeToTimeOfDay,timeOfDayToTime,dayFractionToTimeOfDay,timeOfDayToDayFraction)whereimportData.Time.LocalTime.TimeZoneimportData.Time.Calendar.PrivateimportData.Time.ClockimportData.TypeableimportData.Fixed#if LANGUAGE_Rank2TypesimportData.Data#endif-- | Time of day as represented in hour, minute and second (with picoseconds), typically used to express local time of day.dataTimeOfDay=TimeOfDay{-- | range 0 - 23todHour::Int,-- | range 0 - 59todMin::Int,-- | Note that 0 <= todSec < 61, accomodating leap seconds.-- Any local minute may have a leap second, since leap seconds happen in all zones simultaneouslytodSec::Pico}deriving(Eq,Ord#if LANGUAGE_DeriveDataTypeable#if LANGUAGE_Rank2Types#if HAS_DataPico,Data#endif#endif#endif)instanceTypeableTimeOfDaywheretypeOf_=mkTyConApp(mkTyCon"Data.Time.LocalTime.TimeOfDay.TimeOfDay")[]-- | Hour zeromidnight::TimeOfDaymidnight=TimeOfDay000-- | Hour twelvemidday::TimeOfDaymidday=TimeOfDay1200instanceShowTimeOfDaywhereshow(TimeOfDayhms)=(show2(Just'0')h)++":"++(show2(Just'0')m)++":"++(show2Fixed(Just'0')s)makeTimeOfDayValid::Int->Int->Pico->MaybeTimeOfDaymakeTimeOfDayValidhms=do_<-clipValid023h_<-clipValid059m_<-clipValid060.999999999999sreturn(TimeOfDayhms)-- | Convert a ToD in UTC to a ToD in some timezone, together with a day adjustment.utcToLocalTimeOfDay::TimeZone->TimeOfDay->(Integer,TimeOfDay)utcToLocalTimeOfDayzone(TimeOfDayhms)=(fromIntegral(divh'24),TimeOfDay(modh'24)(modm'60)s)wherem'=m+timeZoneMinuteszoneh'=h+(divm'60)-- | Convert a ToD in some timezone to a ToD in UTC, together with a day adjustment.localToUTCTimeOfDay::TimeZone->TimeOfDay->(Integer,TimeOfDay)localToUTCTimeOfDayzone=utcToLocalTimeOfDay(minutesToTimeZone(negate(timeZoneMinuteszone)))posixDayLength::DiffTimeposixDayLength=fromInteger86400-- | Get a TimeOfDay given a time since midnight.-- Time more than 24h will be converted to leap-seconds.timeToTimeOfDay::DiffTime->TimeOfDaytimeToTimeOfDaydt|dt>=posixDayLength=TimeOfDay2359(60+(realToFrac(dt-posixDayLength)))timeToTimeOfDaydt=TimeOfDay(fromIntegerh)(fromIntegerm)swheres'=realToFracdts=mod's'60m'=div's'60m=mod'm'60h=div'm'60-- | Find out how much time since midnight a given TimeOfDay is.timeOfDayToTime::TimeOfDay->DiffTimetimeOfDayToTime(TimeOfDayhms)=((fromIntegralh)*60+(fromIntegralm))*60+(realToFracs)-- | Get a TimeOfDay given the fraction of a day since midnight.dayFractionToTimeOfDay::Rational->TimeOfDaydayFractionToTimeOfDaydf=timeToTimeOfDay(realToFrac(df*86400))-- | Get the fraction of a day since midnight given a TimeOfDay.timeOfDayToDayFraction::TimeOfDay->RationaltimeOfDayToDayFractiontod=realToFrac(timeOfDayToTimetod)/realToFracposixDayLength