Skip to content

Commit 2fa3b60

Browse files
committed
fix(time): make offset-based rules timezone-independent
1 parent 68b9642 commit 2fa3b60

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

src/LifeOS.Core/ScheduledCommunications/ScheduledCommunicationService.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,9 @@ public bool CanSend(
140140
communication.State == ScheduledCommunicationState.Approved &&
141141
communication.ApprovedAt is not null &&
142142
communication.ScheduledFor <= now &&
143-
!quietHours.Contains(TimeOnly.FromDateTime(now.LocalDateTime));
143+
// Quiet hours apply to the wall-clock time carried by the caller's
144+
// explicit offset, not to the timezone configured on this machine.
145+
!quietHours.Contains(TimeOnly.FromDateTime(now.DateTime));
144146
}
145147

146148
public ScheduledCommunication MarkSent(

src/LifeOS.Core/WorkTime/WorkTimeService.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,10 @@ public WorkDaySummary Summarize(
203203
DateTimeOffset now)
204204
{
205205
WorkTimeEntry[] selected = entries
206-
.Where(entry => DateOnly.FromDateTime(entry.StartedAt.LocalDateTime) == date)
206+
// StartedAt.DateTime preserves the wall-clock date represented by the
207+
// entry's own offset. LocalDateTime would instead convert through the
208+
// machine timezone, making summaries differ between NZ and UTC runners.
209+
.Where(entry => DateOnly.FromDateTime(entry.StartedAt.DateTime) == date)
207210
.ToArray();
208211

209212
TimeSpan total = TimeSpan.FromTicks(selected.Sum(entry => entry.Duration(now).Ticks));

0 commit comments

Comments
 (0)