问题描述
如何从UTCTime
库的time
类型的值中减去n天?
解决方法
import Data.Time
addDaysUtcTime :: UTCTime -> Integer -> UTCTime
addDaysUtcTime t x = addUTCTime (nominalDay * (fromIntegral x)) t
或
import Data.Time
addDaysUtcTime :: UTCTime -> Integer -> UTCTime
addDaysUtcTime t x = t { utctDay = (addDays x (utctDay t))}