denoland / denoland/std

toml: no way to distinuish between different datetime types

Open
#6,591 4 comments 0 reactions 0 assignees View on GitHub
bug needs triage
Dominant language
TypeScript
Stars
3.6k
Forks
681
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.