Skip to content

fix(working_time): compute duration for segments starting at midnight#23

Merged
barredterra merged 2 commits into
alyf-de:version-15from
0xD0M1M0:midnight-fix
May 30, 2026
Merged

fix(working_time): compute duration for segments starting at midnight#23
barredterra merged 2 commits into
alyf-de:version-15from
0xD0M1M0:midnight-fix

Conversation

@0xD0M1M0

Copy link
Copy Markdown
Contributor

Working Time Log rows with from_time 00:00:00 kept duration 0 even when to_time was later the same day. Parent Working Time totals then ignored that segment.

Cause:
set_duration (and related helpers) used if self.from_time. timedelta(0) is falsy in Python, so midnight was skipped.

Reproduce:

  1. Create a Working Time with a log row from 00:00:00 to a later time (e.g. 07:44:00).
  2. Save the document.
  3. Row duration stays 0; working_time / project_time only include other rows.

Fix:
use is not None instead of truthiness for from_time and to_time.

Working Time Log rows with from_time 00:00:00 kept duration 0 even when to_time was later the same day. Parent Working Time totals then ignored that segment.

Cause: set_duration (and related helpers) used `if self.from_time`. timedelta(0) is falsy in Python, so midnight was skipped.

Reproduce:
1. Create a Working Time with a log row from 00:00:00 to a later time (e.g. 07:44:00).
2. Save the document.
3. Row duration stays 0; working_time / project_time only include other rows.

Fix: use `is not None` instead of truthiness for from_time and to_time.
@greptile-apps

greptile-apps Bot commented May 29, 2026

Copy link
Copy Markdown

Confidence Score: 5/5

Safe to merge — a minimal, targeted fix to a well-described calculation bug with no side effects on existing valid inputs.

The change is small and surgical: three guard conditions updated to use explicit None checks instead of truthiness. The only behaviorally significant change is in set_duration, where timedelta(0) being falsy caused midnight start times to silently produce zero duration. All other changes are either no-ops or stylistically equivalent.

No files require special attention.

Sequence Diagram

sequenceDiagram
    participant Caller
    participant WorkingTimeLog
    Caller->>WorkingTimeLog: cleanup_and_set_duration()
    WorkingTimeLog->>WorkingTimeLog: ensure_timedelta() str 00:00:00 to timedelta(0)
    WorkingTimeLog->>WorkingTimeLog: remove_seconds() guard is not None
    WorkingTimeLog->>WorkingTimeLog: uppercase_key()
    WorkingTimeLog->>WorkingTimeLog: set_duration() guard is not None duration computed
Loading

Reviews (1): Last reviewed commit: "fix(working_time): compute duration for ..." | Re-trigger Greptile

Comment thread working_time/working_time/doctype/working_time_log/working_time_log.py Outdated
@barredterra barredterra merged commit 744b1dd into alyf-de:version-15 May 30, 2026
2 checks passed
@barredterra

Copy link
Copy Markdown
Member

🎉 This PR is included in version 15.4.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@0xD0M1M0 0xD0M1M0 deleted the midnight-fix branch May 31, 2026 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants