{-# OPTIONS -Wall -Werror #-}-- #hidemoduleData.Time.Clock.UTC(-- * UTC-- | UTC is time as measured by a clock, corrected to keep pace with the earth by adding or removing-- occasional seconds, known as \"leap seconds\".-- These corrections are not predictable and are announced with six month's notice.-- No table of these corrections is provided, as any program compiled with it would become-- out of date in six months.-- -- If you don't care about leap seconds, use UTCTime and NominalDiffTime for your clock calculations,-- and you'll be fine.UTCTime(..),NominalDiffTime)whereimportData.Time.Calendar.DaysimportData.Time.Clock.ScaleimportData.Fixed-- | This is the simplest representation of UTC.-- It consists of the day number, and a time offset from midnight.-- Note that if a day has a leap second added to it, it will have 86401 seconds.dataUTCTime=UTCTime{-- | the dayutctDay::Day,-- | the time from midnight, 0 <= t < 86401s (because of leap-seconds)utctDayTime::DiffTime}instanceEqUTCTimewhere(UTCTimedata)==(UTCTimedbtb)=(da==db)&&(ta==tb)instanceOrdUTCTimewherecompare(UTCTimedata)(UTCTimedbtb)=case(comparedadb)ofEQ->comparetatbcmp->cmp-- | This is a length of time, as measured by UTC.-- Conversion functions will treat it as seconds.-- It has a precision of 10^-12 s.-- It ignores leap-seconds, so it's not necessarily a fixed amount of clock time.-- For instance, 23:00 UTC + 2 hours of NominalDiffTime = 01:00 UTC (+ 1 day),-- regardless of whether a leap-second intervened.newtypeNominalDiffTime=MkNominalDiffTimePicoderiving(Eq,Ord)instanceEnumNominalDiffTimewheresucc(MkNominalDiffTimea)=MkNominalDiffTime(succa)pred(MkNominalDiffTimea)=MkNominalDiffTime(preda)toEnum=MkNominalDiffTime.toEnumfromEnum(MkNominalDiffTimea)=fromEnumaenumFrom(MkNominalDiffTimea)=fmapMkNominalDiffTime(enumFroma)enumFromThen(MkNominalDiffTimea)(MkNominalDiffTimeb)=fmapMkNominalDiffTime(enumFromThenab)enumFromTo(MkNominalDiffTimea)(MkNominalDiffTimeb)=fmapMkNominalDiffTime(enumFromToab)enumFromThenTo(MkNominalDiffTimea)(MkNominalDiffTimeb)(MkNominalDiffTimec)=fmapMkNominalDiffTime(enumFromThenToabc)instanceShowNominalDiffTimewhereshow(MkNominalDiffTimet)=(showFixedTruet)++"s"-- necessary because H98 doesn't have "cunning newtype" derivationinstanceNumNominalDiffTimewhere(MkNominalDiffTimea)+(MkNominalDiffTimeb)=MkNominalDiffTime(a+b)(MkNominalDiffTimea)-(MkNominalDiffTimeb)=MkNominalDiffTime(a-b)(MkNominalDiffTimea)*(MkNominalDiffTimeb)=MkNominalDiffTime(a*b)negate(MkNominalDiffTimea)=MkNominalDiffTime(negatea)abs(MkNominalDiffTimea)=MkNominalDiffTime(absa)signum(MkNominalDiffTimea)=MkNominalDiffTime(signuma)fromIntegeri=MkNominalDiffTime(fromIntegeri)-- necessary because H98 doesn't have "cunning newtype" derivationinstanceRealNominalDiffTimewheretoRational(MkNominalDiffTimea)=toRationala-- necessary because H98 doesn't have "cunning newtype" derivationinstanceFractionalNominalDiffTimewhere(MkNominalDiffTimea)/(MkNominalDiffTimeb)=MkNominalDiffTime(a/b)recip(MkNominalDiffTimea)=MkNominalDiffTime(recipa)fromRationalr=MkNominalDiffTime(fromRationalr)-- necessary because H98 doesn't have "cunning newtype" derivationinstanceRealFracNominalDiffTimewhereproperFraction(MkNominalDiffTimea)=(i,MkNominalDiffTimef)where(i,f)=properFractionatruncate(MkNominalDiffTimea)=truncatearound(MkNominalDiffTimea)=roundaceiling(MkNominalDiffTimea)=ceilingafloor(MkNominalDiffTimea)=floora