Movatterモバイル変換


[0]ホーム

URL:


modulePostgreSQL.Binary.IntervalwhereimportPostgreSQL.Binary.Preludehiding(months)importqualifiedPostgreSQL.Binary.TimeasTimedataInterval=Interval{micros::Int64,days::Int32,months::Int32}deriving(Show,Eq)-- |-- Oddly enough despite a claim of support of up to 178000000 years in-- <http://www.postgresql.org/docs/9.3/static/datatype-datetime.html Postgres' docs>-- in practice it starts behaving unpredictably after a smaller limit.maxDiffTime::DiffTime=1780000*Time.microsToDiffTimeTime.yearMicrosminDiffTime::DiffTime=negatemaxDiffTimefromDiffTime::DiffTime->MaybeIntervalfromDiffTimex=ifx>maxDiffTime||x<minDiffTimethenNothingelseJust$fromPicosUnsafe(unsafeCoercex)fromPicosUnsafe::Integer->IntervalfromPicosUnsafe=evalState$domodify$flipdiv(10^6)u<-state$swap.flipdivMod(10^6*60*60*24)d<-state$swap.flipdivMod(31)m<-getreturn$Interval(fromIntegralu)(fromIntegrald)(fromIntegralm)toDiffTime::Interval->DiffTimetoDiffTimex=picosecondsToDiffTime$(10^6)*(fromIntegral(microsx)+10^6*60*60*24*(fromIntegral(daysx+31*monthsx)))

[8]ページ先頭

©2009-2025 Movatter.jp