pendulum icon indicating copy to clipboard operation
pendulum copied to clipboard

docs: fix incorrect example outputs in addition_subtraction.md

Open frankgoldfish opened this issue 8 months ago • 1 comments

Summary

Three example output values in the addition/subtraction documentation are incorrect.

Errors fixed

The example simulates a chain of operations starting from pendulum.datetime(2012, 1, 28):

  1. After dt.add(hours=24) → 2012-01-29 00:00:00 (correct)
  2. After dt.add(hours=1) → doc shows '2012-02-25 01:00:00', should be '2012-01-29 01:00:00'
  3. After dt.subtract(hours=1) → doc shows '2012-02-29 00:00:00', should be '2012-01-29 00:00:00' (also Feb 29 doesn't exist in 2012, which is a leap year, making this doubly wrong)
  4. After several minute operations reaching 01:01:00, dt.subtract(minutes=24) → doc shows '2012-01-28 00:00:00', should be '2012-01-28 00:37:00' (01:01 minus 24 minutes = 00:37)

Verified with plain Python datetime arithmetic.

Closes #925

frankgoldfish avatar Mar 17 '26 18:03 frankgoldfish

Merging this PR will not alter performance

✅ 1 untouched benchmark


Comparing frankgoldfish:fix/docs-wrong-calculation-examples-925 (4fa63dd) with master (ae4c405)

Open in CodSpeed

codspeed[bot] avatar Mar 17 '26 22:03 codspeed[bot]