Skip to content

iso8601Show $ CalendarDiffTime (-1) (-1) fails with "*** Exception: formatShow: bad value" #260

Closed as not planned
@tysonzero

Description

@tysonzero

Parsing of course has the equivalent issue:

iso8601ParseM @IO @CalendarDiffTime "P-1MT-1S"
*** Exception: user error (no parse of "P-1MT-1S")

Whilst it seems like the ISO8601 standard may not explicitly support negative interval durations, the Haskell type does, and a variety of tools including PostgreSQL understand negative values within intervals, so I think crashing here is a greater evil than extending the formatting standard to support values the type already supports.

As an example reference: PostgreSQL specifically supports minus signs in the components but not a preceding sign over the entire time interval:

select 'P-1MT1H-1S' :: interval;
P-1MT59M59S

select 'P-1MT1S' :: interval;
P-1MT1S

select 'P-1MT-1S' :: interval;
P-1MT-1S

select '-P1MT1S' :: interval;
ERROR:  invalid input syntax for type interval: "-P1MT1S"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions