Skip to content

DateTime and other constructors to support contracts #1294

Open
@yurkimus

Description

@yurkimus

Feature Request

Ability to do:

new DateTime({ ... })

new DateTime(new DateTime(...))

As far as JS is dynamic and relies mostly on object's shapes, which is working overall in the language e.g.: Promise, URL, Response etc. that would be great to see the same possibility in the driver which is supposed to be used with JS.

I may utilise driver's core in places I want to transform it's output, for example datetime(), instead of manually mapping all the properties to the Date object.

Pitch

  • Less code to write
  • Less code to read
  • Less code to maintain on dev-end
  • This is nature of ecmascript
  • Easy to overload both actual function body and typescript definitions
  • Take a look at the following:
  new Intl.DateTime('en').format(new DateTime(node.createdAt).toStandardDate())

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions