diff --git a/src-python/amazon/ion/equivalence.py b/src-python/amazon/ion/equivalence.py index 01358c3e..d24458eb 100644 --- a/src-python/amazon/ion/equivalence.py +++ b/src-python/amazon/ion/equivalence.py @@ -169,7 +169,7 @@ def _timestamps_eq(a, b): if isinstance(b, Timestamp): # Both operands declare their precisions. They are only equivalent if their precisions are the same. if a.precision is b.precision and a.fractional_precision is b.fractional_precision \ - and a.fractional_seconds == b.fractional_seconds: + and _decimals_eq(a.fractional_seconds, b.fractional_seconds): break return False elif a.precision is not TimestampPrecision.SECOND or a.fractional_precision != MICROSECOND_PRECISION: diff --git a/tests/test_equivalence.py b/tests/test_equivalence.py index 6cb7001e..9e54cb91 100644 --- a/tests/test_equivalence.py +++ b/tests/test_equivalence.py @@ -193,6 +193,11 @@ def _ion_nature(_ion_nature_cls, ion_type, value=None, annotations=()): _ts(1999, 12, 31, 23, 59, off_hours=0, off_minutes=-1, precision=_TP.SECOND), None, ), + ( + # Timestamps with different fractional precisions beyond microseconds are not equivalent. + _timestamp(_ts(2000, precision=_TP.SECOND, fractional_seconds=Decimal('0.000000'))), + _timestamp(_ts(2000, precision=_TP.SECOND, fractional_seconds=Decimal('0.0000000'))), + ), ( # Timestamps with different fractional seconds are not equivalent. _timestamp(_ts(2000, 1, 1, 1, precision=_TP.SECOND, fractional_seconds=Decimal('0.123456789'))),