thingtalk icon indicating copy to clipboard operation
thingtalk copied to clipboard

Switch to Temporal JS module instead of Date

Open gcampax opened this issue 2 years ago • 0 comments

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. [x] include the Temporal polyfill
  2. [x] 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. [x] 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

gcampax avatar Jul 19 '21 03:07 gcampax