Closed peci1 closed 1 year ago
The tests are kind of just repeating the definitions, but I couldn't think of anything better...
I'm not sure if
YEAR
should represent 365 days or 365.2425. I vouch for the latter as it yields smaller errors if you count with large durations (e.g. in 10 years, the 365-day year gives you 2 day error, whereas 365.2425 day has error somewhere around half a day).
Because of this uncertainty - the duration class is simply not designed to handle things like leap years - I would rather not provide a constant for it. Either value will surprise a non-significant amount of users.
Because of this uncertainty - the duration class is simply not designed to handle things like leap years - I would rather not provide a constant for it.
Good point, I'll remove the constant for year
Wow, this PR has somehow slipped through my fingers... But I found it again! I removed the constant for YEAR due to the mentioned ambiguity. I also removed WEEK as it doesn't seem very useful to me.
@dirk-thomas Could you please re-review?
@dirk-thomas friendly ping
@peci1 Sorry, I am not involved in the project anymore for more than 2.5 years.
In that case, this needs to be updated:
(and probably others)
Do you know who the maintainer is?
Unfortunately I don't know. Since the git history doesn't show any new commits, maybe ask on discourse?
@ros-pull-request-builder retest this please
Merging without other approvals since I'm the only maintainer.
@Mergifyio backport melodic-devel
backport melodic-devel
For
Time
,WallTime
andSteadyTime
, I added static constantsMIN
,MAX
,ZERO
andUNINITIALIZED
.For
Duration
andWallDuration
, I added static constantsMIN
,MAX
,ZERO
,NANOSECOND
,MICROSECOND
,MILLISECOND
,SECOND
,MINUTE
,HOUR
,DAY
,WEEK
andYEAR
.In the header files, I added explicit specialization declarations for each of the constants. The build and tests succeeded even without these definitions, but clang suggested to add them and I did so.
I'm not sure if
YEAR
should represent 365 days or 365.2425. I vouch for the latter as it yields smaller errors if you count with large durations (e.g. in 10 years, the 365-day year gives you 2 day error, whereas 365.2425 day has error somewhere around half a day).These constants are mainly syntactic sugar, but I imagine they could become used over time when people know about them.