Skip to content

docs: fix incorrect example outputs in addition_subtraction.md#949

Open
frankgoldfish wants to merge 1 commit into
python-pendulum:masterfrom
frankgoldfish:fix/docs-wrong-calculation-examples-925
Open

docs: fix incorrect example outputs in addition_subtraction.md#949
frankgoldfish wants to merge 1 commit into
python-pendulum:masterfrom
frankgoldfish:fix/docs-wrong-calculation-examples-925

Conversation

@frankgoldfish

Copy link
Copy Markdown

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

The hours and minutes example outputs in the addition/subtraction
documentation contained three incorrect values:
- add(hours=1) after add(hours=24): '2012-02-25' → '2012-01-29'
- subtract(hours=1): '2012-02-29' → '2012-01-29' (also Feb 29 doesn't
  exist in 2012, it's a leap year but still wrong context)
- subtract(minutes=24) after starting at 01:01: '00:00:00' → '00:37:00'

Fixes python-pendulum#925
@codspeed-hq

codspeed-hq Bot commented Mar 17, 2026

Copy link
Copy Markdown

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant