Skip to content

Switch to Temporal JS module instead of Date #366

Description

@gcampax

Temporal (spec, reference) is a newly proposed JS API to handle dates and times. (Currently at Stage 3, which means it is not yet in any ES draft but it is mostly stable)

Unlike traditional JS dates, it is fully timezone aware: it is possible to construct a Temporal object for an arbitrary timezone. This would allow proper conversion between ThingTalk Date and Time.

The steps to incorporate Temporal are:

  1. include the Temporal polyfill
  2. extend the runtime code to handle Temporal objects where Dates are expected (for the "set_time" thingtalk operator, for "==", "+", etc.)
  3. modify Ast.DateValue to carry a Temporal.ZonedDateTime for absolute dates, and treat everything else as incomplete/partial dates
  4. modify the syntax code to use Temporal objects (will require the parser to be timezone-aware)
  5. modify Genie to cope with Temporal objects in ThingTalk results, in ASTs, and in its i18n code
  6. modify Genie's builtin skills to return Temporal objects instead of Date
  7. update type-checking in unit tests to accept Temporal objects
  8. gradually modify all skills that return dates to return Temporal objects

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Nice to have, not working on it for nowbugcleanupClean ups, refactorings, and code improvements that don't fall under other categories

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions