wowprompt

Date and timezone edge-case tests for sale start and end logic

Writes a focused set of unit tests for code that decides whether a sale, coupon or offer is active at a given moment: the exact start and end second, midnight, time zones, daylight saving shifts for overseas users, month ends and leap days. Returns runnable tests in your framework and a list of bugs the tests are likely to expose. Use it before a festive sale goes live on a timer.

A runnable test file covering boundary seconds, midnight, time zones, daylight saving and leap days for a sale-window function, plus a list of likely bugs
The output this prompt produced, unedited.

The prompt

Constraints first

  • Tests never read the real clock; the current time is always injected or frozen.
  • Every test states its time zone explicitly; no test depends on the machine's zone.
  • Each test checks one behaviour and has a name that says what it proves.
  • Do not change the function under test; report suspected bugs separately.

Inputs

  • Language and test framework: [e.g. TypeScript with Vitest, Python with pytest]
  • The function or module: [paste the code]
  • How times are stored: [e.g. UTC timestamps in the database, local strings in config]
  • Who it serves: [e.g. India only on IST, or also users in the UK, US and Gulf]
  • The intended rule in plain words: [e.g. sale runs from 00:00 IST on 1 November to 23:59:59 IST on 8 November, inclusive]

Cover these cases

  1. One second before start, the exact start, one second after.
  2. One second before end, the exact end, one second after; confirm inclusive or exclusive matches the rule.
  3. A user in another zone where the local date differs from IST at the start moment.
  4. A daylight saving change in the user's zone during the sale window.
  5. A window that crosses a month end, and one that includes 29 February.
  6. Start after end, missing dates and malformed strings: the function should fail clearly.

Output format

  1. The complete test file, ready to run.
  2. A table: | Test | Input time and zone | Expected | Why it matters |
  3. Likely bugs in the pasted code, each with the line and a one-line fix.
unit tests for datestimezone bugssale start time codecoupon expiry logicedge case testingtest cases for date functions

How to run this

Copy the prompt and paste it into Gemini, then set the aspect ratio to 3:4. No reference photo is needed for this one.

The prompt is written in Markdown with each part under its own heading, which is what the copy action hands over. Change one section at a time, keeping the rest intact, so you can tell which change did the work.

Related prompts

All productivity