You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
No
Describe the solution you'd like
Export the getDateTimeFromEpoch utility method on the datetime namespace.
This would allow smart contracts to store the blockTimestamp and then parse it back to PlainDateTime at a later stage.
A use case would be how long since some user last ran the smart contract or the smart contract was ran e.g.:
constmap=newPersistentMap<string,number>("f");exportfunctiondoSomeWork(accountId:string):void{constdatetime=datetime.block_datetime();constlast_datetime=datetime.getDateTimeFromEpoch(map.getSome<u64>(accountId));constduration=last_datetime.until(datetime);if(duration.days===0){return'You still have to wait until you can run this method again.…'}map.set(accountId,context.blockTimestamp);
...
return'success';}
Describe alternatives you've considered
I have considered just doing subtraction on u64 values and converting from nanoseconds to seconds.
Copy/Past the getDateTimeFromEpoch() code, which worked fine.
Additional context
Another option would to make the PlainDateTime class available to use.
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
No
Describe the solution you'd like
Export the
getDateTimeFromEpoch
utility method on thedatetime
namespace.This would allow smart contracts to store the
blockTimestamp
and then parse it back to PlainDateTime at a later stage.A use case would be how long since some user last ran the smart contract or the smart contract was ran e.g.:
Describe alternatives you've considered
u64
values and converting from nanoseconds to seconds.getDateTimeFromEpoch()
code, which worked fine.Additional context
Another option would to make the
PlainDateTime
class available to use.The text was updated successfully, but these errors were encountered: