evrythng / epcis2.js

EPCIS 2.0 Javascript SDK
Apache License 2.0
35 stars 4 forks source link

Default to current date and timezone #7

Closed domguinard closed 3 years ago

domguinard commented 3 years ago

(requested by Scott @Zebra) - it would be good to auto-populate EventTime and EventTimeZoneOffset with the client time and timezone if these fields are not present.

 .setEventTime("2021-06-11T20:33:31.116-06:00") // default to current date?
  .setEventTimeZoneOffset("-06:00") // default to current timezone?
domguinard commented 3 years ago

set defaults:

    eventTime = current date/time,
    eventTimeZoneOffset = current time-zone offset,

it would also be good to think if there are other fields we can auto-populate

clementh59 commented 3 years ago

With the next version of epcis2.js, you'll be able to do this:

const o = new ObjectEvent();
const offset = o.getEventTimeZoneOffset(); // returns the actual timeZoneOffset, e.g "+02:00"
const eventTime = o.getEventTime(); // returns the time when the event was created
domguinard commented 3 years ago

Added to release 1.1.0.