bugger.
All challenges/JavaScriptmediumthe-midnight-that-stays-behind-v1
THE INVESTIGATION

The midnight that stays behind

An ISO-style parser wraps 24:00 to the start of the wrong day and accepts impossible end-of-day times.

JavaScriptRepresentation invariantsRegression testing

What’s going wrong

Input is a JSON array of at most 100 strings, each at most 40 characters. Accept exactly YYYY-MM-DDTHH:mm:ss with four-digit year 2000..2199, valid Gregorian month/day and integer time fields. Interpret all input in UTC. Hours 00..23 permit minutes/seconds 00..59. Hour 24 is valid ONLY with minute=second=00 and means midnight at the start of the next day. Reject malformed grammar, invalid dates and invalid time components with null. Otherwise print the normalized UTC ISO timestamp with .000Z. Do not accept leap seconds, timezones, fractional seconds or shorter numeric fields. Return one result per input string.

Expected behavior

Preserve day carry while validating a special boundary representation.

Reproduction

01 End of day
["2024-04-30T24:00:00"]
["2024-05-01T00:00:00.000Z"]
02 Ordinary time control
["2024-04-30T13:02:01"]
["2024-04-30T13:02:01.000Z"]
03 Start of day control
["2024-04-30T00:00:00"]
["2024-04-30T00:00:00.000Z"]

Before you begin

  • JavaScript functions, arrays and objects
  • Build on consistent units: converting an hour representation must preserve both elapsed time and calendar carry.

Need a nudge?

Reveal one investigation hint at a time. Try each clue before opening the next.

    The bug is intentional. Run the starter code to see it fail, then work toward a fix. Difficulty is provisional.
    Read-only preview
    Ready when you are
    Every fix starts with a failing test.

    Read the report, then sign in to start your investigation.