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

Unexpected behaviour of DateTime getDay method #731

Open
adrianffletcher opened this issue Jan 10, 2020 · 5 comments
Open

Unexpected behaviour of DateTime getDay method #731

adrianffletcher opened this issue Jan 10, 2020 · 5 comments

Comments

@adrianffletcher
Copy link

When the getDay method is called in ergo on a DateTime from a request that was created using the String "2020-01-02" the value returned is 1 rather than 2.

To Reproduce
Run 'cicero trigger' on the attached smart clause template.

Expected behavior
Based on the contract logic I would expect 2 to be returned and no payment obligation to be raised. In fact a payment obligation is raised.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: MacOS

Additional context
This was running in the New York locale and this may be a timezone issue.

@adrianffletcher
Copy link
Author

[email protected]

@jeromesimeon
Copy link
Member

It's most likely a timezone issue, can you run with cicero --currentTime= "2020-01-23T00:00:00-05:00" or cicero --currentTime= "2020-01-23T00:00:00Z" to see the difference?

Currently dates are always interpreted as a Date/Time with zero hours/minutes/seconds and are interpreted as instants in a given timezone. This means, it is always preferable to provide explicit timezones to avoid confusion in the request and/or for execution.

I would be interested to know if there are requirements for a different behaviour.

@adrianffletcher
Copy link
Author

Yes, this is a timezone issue. On reflection I think we need a logical Date object that does not include timezone information for this kind of logic.

@jeromesimeon
Copy link
Member

Yes, this is a timezone issue. On reflection I think we need a logical Date object that does not include timezone information for this kind of logic.

Maybe...what does a date without a timezone mean? If the contract says by January 24th, 2020 I think there would always be an implicit timezone? (that date in Paris or Canberra).

@adrianffletcher
Copy link
Author

Yes, you are right, there would be an implicit timezone but the object would behave the same regardless of the timezone. So if you call getDay on "2020-01-02" then you will always get 2 regardless of timezone.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants