Skip to content
This repository has been archived by the owner on Sep 7, 2023. It is now read-only.

Manage and preserve timezone information #515

Closed
4 of 5 tasks
jeromesimeon opened this issue Jan 15, 2019 · 2 comments
Closed
4 of 5 tasks

Manage and preserve timezone information #515

jeromesimeon opened this issue Jan 15, 2019 · 2 comments
Labels
Help Wanted 🆘 Extra attention is needed Type: Feature Request 🛍️ New feature or request

Comments

@jeromesimeon
Copy link
Member

jeromesimeon commented Jan 15, 2019

Executing operations on date and time always returns output in UTC, even if it uses the local timezone of the engine. This can lead to confusion, for instance, calling startOf endOf on EST returns EST results but converted to UTC:

bash-3.2$ cat logic.ergo 
namespace org.accordproject.startendtest

import org.accordproject.time.*

contract StartEndTest over TemplateModel {
  // Simple Clause
    clause test(request : Request) : TestResponse {
    let date : DateTime = dateTime("2018-01-01T12:00:00.000Z");
    return TestResponse{
      startOfDay: startOf(date, "days"),
      endOfDay: endOf(date, "days")
    }
  }
}
bash-3.2$ ergorun model.cto logic.ergo --contract contract.json --request request.json --state state.json --contractname org.accordproject.startendtest.StartEndTest
12:22:11 - info:
{
  "response": {
    "startOfDay": "2018-01-01T05:00:00.000Z",
    "endOfDay": "2018-01-02T04:59:59.999Z",
    "$class": "org.accordproject.startendtest.TestResponse"
  },
  "state": {
    "$class": "org.accordproject.cicero.contract.AccordContractState",
    "stateId": "1"
  },
  "emit": []
}

The DateTime support in Ergo should allow:

  • To parse/print in a given timezone
  • To set the local timezone (possibly it should be part of the context)
  • Maintain the timezone throughout the processing
  • Handle UTC offset (e.g., +5:00)
  • Handle legal timezones (e.g., EST)
@jeromesimeon
Copy link
Member Author

Some better support for utcOffset in PR #522

@jeromesimeon
Copy link
Member Author

Contract time zone is now obtained from API during execution and time zone-dependent operations take it into account.

See release 0.7.0

No plans to support legal time zones at the moment so I’m closing.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Help Wanted 🆘 Extra attention is needed Type: Feature Request 🛍️ New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant