Skip to content

SignedDuration's Display should use upper case letter #190

@tisonkun

Description

@tisonkun

It seems in the definition of ISO 8601 (RFC-3339), it wrotes: https://datatracker.ietf.org/doc/html/rfc3339#appendix-A

Durations:

   dur-second        = 1*DIGIT "S"
   dur-minute        = 1*DIGIT "M" [dur-second]
   dur-hour          = 1*DIGIT "H" [dur-minute]
   dur-time          = "T" (dur-hour / dur-minute / dur-second)
   dur-day           = 1*DIGIT "D"
   dur-week          = 1*DIGIT "W"
   dur-month         = 1*DIGIT "M" [dur-day]
   dur-year          = 1*DIGIT "Y" [dur-month]
   dur-date          = (dur-day / dur-month / dur-year) [dur-time]

Note that the unit letter here is upper case, while jiff's Display prints lower case.

It would fail when using format("{}", dur) to cast the repr to a PostgreSQL's Interval: https://www.postgresql.org/docs/current/datatype-datetime.html#DATATYPE-INTERVAL-INPUT

... where only upper case letters are accepted:

scopedb_meta=# SELECT INTERVAL 'PT10m';
ERROR:  invalid input syntax for type interval: "PT10m"
LINE 1: SELECT INTERVAL 'PT10m';
                        ^
scopedb_meta=# SELECT INTERVAL 'PT10M';
 interval 
----------
 00:10:00
(1 row)

I'm not sure if it's intended or if somewhere there only accepts lower case letters. But the described PG interval integration is a failed case I encountered.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions