Debug a Statement Cycle Bug Caused by UTC Timestamps
Last updated: November 29, 2026
Quick Overview
A function that assigns card transactions to a statement cycle sometimes puts late-evening purchases on the next month's statement. Find the bug, fix it, and write tests that would have caught it, including around daylight saving time.
Capital One
November 29, 20260
0
0 solved
A function that assigns card transactions to a statement cycle sometimes puts late-evening purchases on the next month's statement. Find the bug, fix it, and write tests that would have caught it, including around daylight saving time.
Debugging questions in Capital One's software engineering screens often use realistic banking bugs. Here, transactions are stored in UTC while statement cycles close on Eastern time, so a 9:30 pm purchase on the close date lands on the wrong statement. The interviewer checks systematic debugging and test design.
What the Interviewer Expects
- Reproduce the bug with a concrete failing input
- Identify the UTC versus local date mismatch
- Fix by converting to the business time zone before taking the date
- Reject naive datetimes instead of guessing their zone
- Write boundary tests around the cutoff, DST, and year end
Key Topics to Cover
How to Approach This
- Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
- Choose data structures based on access patterns, not familiarity.
- Prefer immutable data and message passing over shared mutable state for concurrency.
- Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
- How would you find all statements affected in production?
- Why would tests pass on a developer laptop but fail in CI?
- What if cardholders are in different time zones but the cycle is defined in Eastern time?
- How would you make tests independent of the machine's local time zone?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Requirements
- Input: a transaction timestamp stored in UTC and the account's close day (1 to 28).
- Output: the closing date of the statement the transaction belongs to.
- Rule: a transaction posts to the cycle t...
High-Level Design
Reproduce first: a purchase at 9:30 pm ET on March 15 (EDT, UTC-4) is stored as 01:30 UTC on March 16. The buggy code takes txn_utc.date(), sees March 16, which is past the close day 15, and assigns...