Overview
Time bugs often appear at month ends, leap days, daylight-saving transitions and around midnight in different time zones.
Distinguish instants from dates
A timestamp represents an instant. A calendar date such as a billing day may not. Model each concept explicitly and avoid silently interpreting a date-only value in the server's default time zone.
Inject a clock
Pass the current time into domain logic or use a clock interface. Tests can then set a fixed instant and verify expiry, scheduling and reporting boundaries without waiting.
Build a boundary matrix
Test start and end instants, daylight-saving transitions for relevant zones, leap years and month changes. Verify whether intervals are inclusive or exclusive.
Keep environment stable
Set the test time zone explicitly and test conversions using named IANA zones rather than fixed offsets when daylight-saving rules matter.