-
Notifications
You must be signed in to change notification settings - Fork 11.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Date utility #533
Comments
@martriay I don't think this can be done efficiently with a library, but it looks like it could be a good addition to the base Solidity language. Would you mind opening an issue there? |
Could you point me to successful uses (if any) of dates/timestamps in smart contracts?
(https://blog.acolyer.org/2017/02/23/making-smart-contracts-smarter/) |
They are not unusable for many cases. You just have to be careful where you use them. |
As @federicobond said, there are several non-critical use cases (as long as they can resist a 900s error). That being said, dates represented in |
Hm, interesting. Closing this issue though to merge it with #1531. |
Smart contracts have to deal with dates for a multiplicity of reasons. Nowadays this is not only done by placing a magic constant but also by representing them as seconds since unix epoch, which is not human-readable and error prone.
Smart contract programming is no different discipline from "regular" software programming as we tend to refactor existing code or change our minds on a given functionality. When this happens, arbitrary numbers representing old dates are difficult to catch.
To address this issue I suggest a
Date
utility for defining dates in a human-readable manner following javascript's Date interface as it's something we're used to.Thus if we wanted to state that a given crowdsale starts on October 31st at 16:30 UTC, we would write it like this:
Opening up the topic for discussion.
The text was updated successfully, but these errors were encountered: