Skip to content

toml: no way to distinuish between different datetime types #6591

Open
@arp242

Description

@arp242

TOML has four different datetime types:

dt = 2012-01-01 12:13:14+08:00   # datetime: full datetime, with timezone
l  = 2012-01-01 12:13:14         # local-datetime: full date, without timezone
d  = 2012-01-01                  # local-date: only the date, without timezone
t  = 12:13:14                    # local-time: only the time, without timezone

Currently there doesn't seem any way to distinguish between them;

If I call stringify() on the above document I end up with:

dt = 2012-01-01T04:13:14.000
l  = 2012-01-01T12:13:14.000
d  = 2012-01-01T00:00:00.000
t  = "12:13:14"

There are actually a few problems here:

  • The timezone information in dt is lost. It's applied on parse, but after that you can never know what TZ it was in and this information is list. This is also why stringify() writes back the dt aas a local-datetime rather than datetime, which is typically taken as "the TZ of the computer running it", which may be different.

  • The local-date is written back as a local-datetime. I suppose this could be considered a valid choice, but it's not exactly identical as 2012-01-01T00:00:00 denotes a specific time, and 2012-01-01 doesn't.

  • The local-time is parsed as a string(?!)

To resolve these problems, deno's toml should probably offer a way to distinguish between the different datetime types, which is what most other implementations do.

Note: I'm not really a TypeScript/Deno developer and I have no opinion on what the best way to solve this is, I'm just trying to integrate the toml-test suite, and this is causing many tests to fail.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions