FAILURE MAP
← Case archive

FA-311 / Time representation / Open access

Duration formatting wraps elapsed hours at midnight · case 01

A multi-day duration loses its day component, and a negative duration looks like a positive time of day.

Verified by executionVariant 1 · 7 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

The duration is decomposed using a normalized seconds-within-day field or a modulo-twenty-four hour field.

VERIFIED REPAIR

Extract the sign once, then decompose the absolute integer microsecond count without wrapping the hour total.

Unsuccessful approach: Adding a sign and absolute value fixes negative display but retaining modulo-twenty-four hours still discards full days.

Case contract

Format an integer microsecond duration as optional '-' followed by H:MM:SS.ffffff. Hours are unbounded, minutes and seconds are 00 through 59, and zero has no negative sign.

Why this case matters

Elapsed durations are not times of day. Reusing clock formatting can conceal long outages or reverse the apparent sign of a measurement.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
from datetime import timedelta
N = 1
observations = []
def solve(microseconds):
    value = timedelta(microseconds=microseconds)
    hours, rest = divmod(value.seconds, 3600)
    minutes, seconds = divmod(rest, 60)
    return f'{hours}:{minutes:02d}:{seconds:02d}.{value.microseconds:06d}'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
hours = 24 * N + 3
value = (hours * 3600 + 2 * 60 + 1) * 1000000 + N
check('multi-day positive duration', solve(value), f'{hours}:02:01.{N:06d}')
check('multi-day negative duration', solve(-value), f'-{hours}:02:01.{N:06d}')
check('negative subsecond value', solve(-N), f'-0:00:00.{N:06d}')
check('positive subsecond value', solve(N), f'0:00:00.{N:06d}')
check('zero has no sign', solve(0), '0:00:00.000000')
check('whole minute', solve(60000000), '0:01:00.000000')
check('exact full day is twenty-four hours', solve(86400000000), '24:00:00.000000')
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
multi-day positive duration3:02:01.00000127:02:01.000001Failed
multi-day negative duration20:57:58.999999-27:02:01.000001Failed
negative subsecond value23:59:59.999999-0:00:00.000001Failed
positive subsecond value0:00:00.0000010:00:00.000001Passed
zero has no sign0:00:00.0000000:00:00.000000Passed
whole minute0:01:00.0000000:01:00.000000Passed
exact full day is twenty-four hours0:00:00.00000024:00:00.000000Failed

SHA-256 / ebf02fcfe2b33cdf5aff9f8e9216082e771bb048ea908ea6898665e25843cb7d

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
from datetime import timedelta
N = 1
observations = []
def solve(microseconds):
    seconds, fraction = divmod(abs(microseconds), 1000000)
    hours, rest = divmod(seconds, 3600)
    minutes, seconds = divmod(rest, 60)
    sign = '-' if microseconds < 0 else ''
    return f'{sign}{hours % 24}:{minutes:02d}:{seconds:02d}.{fraction:06d}'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
hours = 24 * N + 3
value = (hours * 3600 + 2 * 60 + 1) * 1000000 + N
check('multi-day positive duration', solve(value), f'{hours}:02:01.{N:06d}')
check('multi-day negative duration', solve(-value), f'-{hours}:02:01.{N:06d}')
check('negative subsecond value', solve(-N), f'-0:00:00.{N:06d}')
check('positive subsecond value', solve(N), f'0:00:00.{N:06d}')
check('zero has no sign', solve(0), '0:00:00.000000')
check('whole minute', solve(60000000), '0:01:00.000000')
check('exact full day is twenty-four hours', solve(86400000000), '24:00:00.000000')
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
multi-day positive duration3:02:01.00000127:02:01.000001Failed
multi-day negative duration-3:02:01.000001-27:02:01.000001Failed
negative subsecond value-0:00:00.000001-0:00:00.000001Passed
positive subsecond value0:00:00.0000010:00:00.000001Passed
zero has no sign0:00:00.0000000:00:00.000000Passed
whole minute0:01:00.0000000:01:00.000000Passed
exact full day is twenty-four hours0:00:00.00000024:00:00.000000Failed

SHA-256 / 213ebe73305bcd24606cd05d151f45578d151d9dc13a12b687dfaaffb845ddbf

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
from datetime import timedelta
N = 1
observations = []
def solve(microseconds):
    seconds, fraction = divmod(abs(microseconds), 1000000)
    hours, rest = divmod(seconds, 3600)
    minutes, seconds = divmod(rest, 60)
    sign = '-' if microseconds < 0 else ''
    return f'{sign}{hours}:{minutes:02d}:{seconds:02d}.{fraction:06d}'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
hours = 24 * N + 3
value = (hours * 3600 + 2 * 60 + 1) * 1000000 + N
check('multi-day positive duration', solve(value), f'{hours}:02:01.{N:06d}')
check('multi-day negative duration', solve(-value), f'-{hours}:02:01.{N:06d}')
check('negative subsecond value', solve(-N), f'-0:00:00.{N:06d}')
check('positive subsecond value', solve(N), f'0:00:00.{N:06d}')
check('zero has no sign', solve(0), '0:00:00.000000')
check('whole minute', solve(60000000), '0:01:00.000000')
check('exact full day is twenty-four hours', solve(86400000000), '24:00:00.000000')
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
multi-day positive duration27:02:01.00000127:02:01.000001Passed
multi-day negative duration-27:02:01.000001-27:02:01.000001Passed
negative subsecond value-0:00:00.000001-0:00:00.000001Passed
positive subsecond value0:00:00.0000010:00:00.000001Passed
zero has no sign0:00:00.0000000:00:00.000000Passed
whole minute0:01:00.0000000:01:00.000000Passed
exact full day is twenty-four hours24:00:00.00000024:00:00.000000Passed

SHA-256 / c7322b30a8440f8a563e4e21bd22eeb1ee4de1575a7e4d54c18a5b92429a63d7

Verification & scope

This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-29T14:36:52.069500+00:00.

Case digest / 98c19df8bd50176af9fd95e0ca33527a178f02c118889df73488bc84b3b76ca8