closerdao / proof-of-presence

TDF smart contracts
MIT License
2 stars 3 forks source link

TestTimestamp fails when user is in GMT+13 (and bookings might be broken) #46

Closed juliencharrel closed 1 year ago

juliencharrel commented 1 year ago

Maybe in other timezones too.

arturictus commented 1 year ago

and bookings might be broken

can you elaborate how this would affect bookings in the contracts?

The current issue is in test, the TS that is testing the timestamp is doing calculations with a difference timezone that the test hardhat EVM. That's the main cause of this error.

Timestamps are calculated in the contract, the client should send year and day of the year (1-365). Client should make sure that those two params are calculated from a UTC time before sending them to the blockchain.

juliencharrel commented 1 year ago

Why should the client calculate that from a UTC time? If the client only sends year and day of the year that can be independent of timezoning

juliencharrel commented 1 year ago

And good to know it does not impact booking

arturictus commented 1 year ago

Why should the client calculate that from a UTC time? If the client only sends year and day of the year that can be independent of timezoning

usually that should be the case but client has to make sure that if you click 01/02/2023 at 23:00 the dayOfYear calculation returns 32 not 33 which should be obvious but if you execute in the client and do some time calculations to generate the day of the year could mess up this result. Just to be aware

arturictus commented 1 year ago

CI is working, would be nice that the next developer that finds this issue fixes it. I close it for now