accordproject / ergo

Programming Language for Smart Legal Contracts
https://accordproject.org/projects/ergo
Apache License 2.0
158 stars 55 forks source link

Implement DateTime within Ergo #345

Open kach opened 6 years ago

kach commented 6 years ago

This can be done now that we have importing working. Implementing DateTime within Ergo would:

  1. Simplify the compiler because we don't have to deal with foreign data
  2. Save us the trouble of implementing native datetime support in every backend
  3. Give us free eval for datetime operations, e.g. in the REPL
kach commented 6 years ago

This is a good issue for contributors because it doesn't require any knowledge of compiler internals; all the code would be written in Ergo itself.

mbtamuli commented 5 years ago

Can I work on this issue?

mbtamuli commented 5 years ago

Can someone provide a hint or pointer as to what needs to be done?

jeromesimeon commented 5 years ago

@mbtamuli Sorry for the lag, we're in the middle of a release which makes it hard to track everything.

This is a great issue to pick! Also a pretty ambitious one. Ultimately the goal would be to re-implement the date and time library in Ergo (currently based on the primitive type DateTime) directly as an Ergo library. The current date and time library is documented here: https://docs.accordproject.org/docs/ref-logic-stdlib.html#functions-on-datetime and parsing/printing of DateTime values is based on the ISO 8601 standard: https://en.wikipedia.org/wiki/ISO_8601

If you consider all the different ways people write dates, issues with timezones, leap years, etc. I could consider this a fairly challenging issue to tackle, so I wouldn't try to do everything at once, but start with a more bite size task first.

That could simply look like:

  1. Create a separate ErgoDateTime structure that captures date/time information (year, month, etc)
  2. Assume everything is in UTC (so not try to tackle timezones)
  3. Not try to address parsing/serialization for the time being, but instead have functions to convert between the current DateTime and the new ErgoDateTime

Let me know if you think that makes sense. Also feel free to join the Ergo calls on Friday morning (9am EST) -- information about those can be found on the #technology-ergo channel on the Accord Project Slack!

mbtamuli commented 5 years ago

Won't be able to work on this immediately. @irmerk you can reassign to someone else if they want to take this up.

Anjani-225 commented 4 years ago

Hey Could I work on this issue?

jeromesimeon commented 4 years ago

Sure @Anjani-225 !

Anjani-225 commented 4 years ago

Hello Ive implemented a new library with has the DateTime library in ergo itself in this pull request. I have drafted the library keeping in mind the gas costs. I have ignored time zones for now. Please do let me know on how to improve upon it.