Mutare.Mutators.DateTimeLiteral (mutare v0.1.0)

Copy Markdown View Source

Calendar-sigil mutations: shift a date/time literal by one unit.

  • ~D[2020-01-01]~D[2020-01-02] (+1 day)
  • ~T[12:00:00]~T[12:00:01] (+1 second)
  • ~N[…] → +1 day (NaiveDateTime)
  • ~U[…Z] → +1 day (DateTime, UTC)

The temporal counterpart of Mutare.Mutators.IntegerLiteral's off-by-one: a one-unit shift is the boundary nudge that catches ==/</> comparisons and date arithmetic a too-weak suite leaves unpinned.

Why a shift, not a sentinel. Calendar sigils are validated at compile time (~D[2020-13-99] is a compile error), so a mutation must stay a valid date/time. The literal is parsed, shifted by one unit, and re-serialised, so the result is always a real calendar value.

At the end of the sigil-supported year range that forward shift would itself be a compile error (~D[9999-12-31] renders as 10000-01-01, which the sigil rejects — ISO 8601 wants four digits), so the nudge runs backwards there instead and the mutant is still a one-unit boundary shift. Each candidate is re-parsed before it is offered, which is the same check the compiler performs; a literal no direction can shift produces no mutant.

Only non-interpolated sigils are reached (calendar sigils require literal content).