metomi / isodatetime

:date: :watch: Python ISO 8601 date time parser and data model/manipulation utilities
GNU Lesser General Public License v3.0
37 stars 20 forks source link

TimePoint dumping buggy for decimals that round up to 1 #184

Closed MetRonnie closed 3 years ago

MetRonnie commented 4 years ago

Example:

>>> TimePoint(year=2020, second_of_minute=5, second_of_minute_decimal=0.9999999)
<metomi.isodatetime.data.TimePoint: 2020-01-01T00:00:05,1.Z>

Instead of 00:00:05,1.Z it should be 00:00:06,0Z.

That would make the behaviour in line with rounding down, e.g.

>>> TimePoint(year=2020, second_of_minute=6, second_of_minute_decimal=0.000000000001)
<metomi.isodatetime.data.TimePoint: 2020-01-01T00:00:06,0Z>

Another question is if the stripping of trailing zeroes when rounding to 6 decimal places is misleading about the precision/number of significant figures