arrow-py / arrow-py/arrow

Error in datediff calculation

Open
#1,106 3 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
9.1k
Forks
784
PR merge metrics
No merged PRs in 30d

Description

If i calculate the time difference between 2 datetime objects, the result is incorrect. Here an example:

import arrow
start = arrow.get('28.04.2022 14:00','DD.MM.YYYY HH:mm' )
end = arrow.now()
print(f'Start-Datetime: {start}')
print(f'End-Datetime : {end}')
print(f'Time-Difference: {end-start}')

Start-Datetime: 2022-04-28T14:00:00+00:00
End-Datetime : 2022-04-28T16:17:06.144073+02:00
Time-Difference: 0:17:06.144073

The correct Time-Difference should be 2:17:06......

## System Info

- 🖥 **Windows 10 21H1**:
- 🐍 **Python 3.9.9**:
- 🏹 **Arrow 1.2.1**:

Contributor guide

No contributing guide indexed for this repository

Research direction

No source file or test is named. Start by reproducing the supplied Python example with Arrow 1.2.1, then trace the datetime subtraction and timezone handling; the issue is done when the reported inputs produce the expected two-hour difference.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.