2017-04-11 70 views
0

表演在lubridate這個基本操作:Lubridate返回負MM和SS

library("lubridate")  
seconds_to_period(10 * 3600) + hours(24) - seconds_to_period(19.67 * 3600) 

結果:

"15H -40M -12S" 

我期待:

"14H 19M 48S" 

它是正常的嗎?

+1

[此github上的問題(https://github.com/hadley/lubridate/issues/75)使得它好像這不是期望的行爲。也許提交錯誤報告? – MrFlick

+0

關於這個問題的更多內容在這裏討論:https://github.com/hadley/lubridate/issues/503 –

回答

1

我們可以做數值運算上秒鐘,然後申請seconds_to_period

seconds_to_period((10*3600 + 24*3600) - (19.67 * 3600)) 
#[1] "14H 19M 48S"