You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
lubridate hms function doesn't Roll hrs, min and secs correctly when added. #417
There is no automatic normalization of period components in lubridate. Components could be whatever and should give same result when used with date-times.
While normalization of hms would make sense, how would you you normalize periods that contain days months and years?
I believe the principle should be the same. In hms we need roll minutes and seconds and normalise hours accordingly
and in periods such as you describe it is days and months; years need normalising.
However, I currently do not have a solutions to it.
and in periods such as you describe it is days and months; years need normalising.
I don't understand this.
hms produces a period; so does period(year=1,month=20,m=100,s=1). If we roll in hms then we should roll in period as well and that's not possible because you cannot roll higher units.
What's your use case more concretely? Why do you need hms to roll up? If it does roll, when do you propose it to stop rolling, hours or days?
The case is , If i have a csv file that contain two columns of hours (hh:mm:ss) and i wish to know the total hours; a result such as this 40H 70M 70S isn't exactly right.
I am not concerned with periods including month or year. I am just concerned with (hh:mm:ss)
So I now have begun to think if its at all possible in R or perhaps I am too inclined to think in a csv(excel) way of storing hours.
Hope this explains my use case and the thought that i present.
We should probably have normalize_period, or roll_period function to deal with such normalization. We can also add an optional argument to hms to automatically normalize the output. Doing it in arithmetic operations is tricky because there is no clear cut definition of rolling and it would add computational burden with not so clear benefits.
Activity
vspinu commentedon May 23, 2016
There is no automatic normalization of period components in lubridate. Components could be whatever and should give same result when used with date-times.
While normalization of hms would make sense, how would you you normalize periods that contain days months and years?
shoaibkhanz commentedon May 24, 2016
I believe the principle should be the same. In hms we need roll minutes and seconds and normalise hours accordingly
and in periods such as you describe it is days and months; years need normalising.
However, I currently do not have a solutions to it.
Do you agree to this?
vspinu commentedon May 24, 2016
I don't understand this.
hmsproduces a period; so doesperiod(year=1,month=20,m=100,s=1). If we roll inhmsthen we should roll inperiodas well and that's not possible because you cannot roll higher units.What's your use case more concretely? Why do you need hms to roll up? If it does roll, when do you propose it to stop rolling, hours or days?
shoaibkhanz commentedon May 25, 2016
The case is , If i have a csv file that contain two columns of hours (hh:mm:ss) and i wish to know the total hours; a result such as this
40H 70M 70Sisn't exactly right.I am not concerned with
periodsincludingmonth or year. I am just concerned with(hh:mm:ss)So I now have begun to think if its at all possible in R or perhaps I am too inclined to think in a csv(excel) way of storing hours.
Hope this explains my use case and the thought that i present.
vspinu commentedon May 26, 2016
We should probably have
normalize_period, orroll_periodfunction to deal with such normalization. We can also add an optional argument tohmsto automatically normalize the output. Doing it in arithmetic operations is tricky because there is no clear cut definition of rolling and it would add computational burden with not so clear benefits.vspinu commentedon Aug 17, 2016
I have added
roll=TRUEargument which rolls up to hours. There is no much point in rolling towards days.I am still thinking if I should make that argument TRUE by default.