Time Zones and Pay Periods: Getting Date Boundaries Right in .NET
Ali Saad · November 9, 2026 · 4 min read
A report can select the right employees and still produce the wrong hours because its date boundaries are wrong. Workforce systems make this especially visible: shifts cross midnight, customers operate in different regions, and a calendar day is not always a fixed number of elapsed hours. Before writing a date filter, I want to know what the business means by a day and which clock defines it.
Separate dates from moments
An employment start date and a clock-in event describe different things. The first may be a calendar date with no time of day. The second is an occurrence on a timeline. Treating both as loosely formatted strings makes it easy to apply a conversion where none belongs, or to lose the context needed for a real event.
In .NET, DateOnly can express a calendar date, while DateTimeOffset can represent a date and time with a UTC offset. An offset does not identify a time zone or its future daylight-saving rules. When regional rules matter, preserve the relevant time-zone identifier and use it deliberately rather than inferring it from an offset.
Establish whose calendar owns the period
Suppose an export covers Monday through Sunday for a customer whose payroll calendar follows a particular region. The server's local midnight is not automatically the correct boundary. Calculate the start and end using the customer's business calendar, then translate those boundaries into the representation used for stored event timestamps.
Ask whether the period belongs to a work location, employee, customer, or payroll group. A distributed organization may have several valid answers for different reports. Document that choice beside the report's requirements, because a technically consistent timezone conversion can still implement the wrong business definition.
Use explicit interval rules
A half-open interval includes the start and excludes the next period's start. For example, events satisfy timestamp greater than or equal to the beginning and strictly less than the end. This avoids inventing a final instant such as 23:59:59.999, which can depend on storage precision and omit valid events.
Adjacent periods then share a boundary without counting the same event twice. However, this rule only selects events. It does not decide how a shift spanning the boundary should be allocated. That requires a separate policy: split elapsed time, assign the entire shift to its starting day, or follow another approved rule.
Handle clock changes deliberately
Daylight-saving transitions can create local times that do not exist or occur twice. A local timestamp without an offset may therefore be insufficient to identify an event. An import should detect that ambiguity and apply an agreed resolution rather than silently assuming the machine's local settings describe the customer's intent.
Also separate elapsed duration from displayed clock differences. A shift's start and end may look several hours apart on a wall clock while a clock transition changes the actual elapsed time. Payroll rounding, break deductions, and overtime allocation are additional business rules; converting timestamps does not settle those calculations.
Build boundary-focused examples
Useful cases include a shift ending exactly at period start, an event at the next period's first instant, a shift crossing midnight, and both daylight-saving transitions for a relevant region. Include customers without daylight saving as well. Test report selection and duration allocation separately so a passing total does not hide incorrect row ownership.
For support, show the business period, its time zone, and the interpreted boundaries when diagnosing a discrepancy. That information is more useful than a bare date range. It lets an analyst compare the system's interpretation with the payroll calendar before anyone changes a query.
Key takeaways
- ✓Model calendar dates separately from timestamped events.
- ✓Define the business time zone before filtering data.
- ✓Prefer explicit start-inclusive, end-exclusive intervals.
- ✓Test clock transitions and shifts that cross boundaries.
Conclusion
Reliable date handling starts with clear business ownership of time. Choosing appropriate .NET types helps preserve that meaning, while explicit boundaries make it testable. The most valuable question is often not how to convert a timestamp, but which calendar the result is supposed to follow.