簡體   English   中英

如何從 UTCTime 中增加或減少 n 天?

[英]How to add or subtract n days from UTCTime?

如何從time庫中的UTCTime類型的值中添加/減去 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))}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM