期间和期限之间的差异

与持续时间不同,可以使用句点来精确建模时钟时间,而无需知道何时发生诸如闰秒,闰日和 DST 更改等事件。

start_2012 <- ymd_hms("2012-01-01 12:00:00")
## [1] "2012-01-01 12:00:00 UTC"

# period() considers leap year calculations.
start_2012 + period(1, "years")
## [1] "2013-01-01 12:00:00 UTC"

# Here duration() doesn't consider leap year calculations. 
start_2012 + duration(1)
## [1] "2012-12-31 12:00:00 UTC"