Skip to content

Date library using Joda-Time#882

Closed
eregon wants to merge 2 commits intomasterfrom
date
Closed

Date library using Joda-Time#882
eregon wants to merge 2 commits intomasterfrom
date

Conversation

@eregon
Copy link
Member

@eregon eregon commented Jul 13, 2013

Here are the first commits.

There are many problems for now.

  • Date/DateTime constructors are very liberal for the arguments, they accept negative args and such. Replacing them with Joda is very hard (except for maybe for Date.civil).
  • Therefore, decoupling from ajd is pretty hard, and anyway we need ajd in a couple of case (Date.jd, Date#ajd, etc).
  • Joda's DateTime only has ms precision, but date.rb says it has ns, but actually is arbitrary (through Rational).
    • So we are almost obligated to keep @ajd in the instance as a Rational to keep the precision.

I am not sure Joda's DateTime methods such as getYear() provide a significant speedup, I should measure that to see if it is worth changing (it is changed for now when precision is not an issue).

There is an additonnal test failure about meeting a Bignum (should have been a long). That would mean that time is not representable by Joda-Time, I'll check.

Maybe the biggest problem is in parsing/dumping with str{f,p}time? In that case I should probably focus on that and the solution of building lazily the Joda DateTime might be a good option.

eregon added 2 commits July 10, 2013 16:47
(MRI did remove tabs in *.rb but after date was made native)
* Tests are unaffected by this change.
* Zone offset and Gregorian cutover are computed from the DateTime.
* They are still copied in instances variables for ease of compatibility with current code.
* @ajd need to be preserved for now as DateTime only has millisecond precision,
  date.rb has arbitrary (although mentioned not expected > ns) (via Rational).
* Joda methods are used for year,week,day,hour,min and second
  (but not fractions since it might be imprecise).
@BanzaiMan
Copy link
Member

Spacing seems to be messed up. Could you fix it?

@eregon
Copy link
Member Author

eregon commented Jul 15, 2013

@BanzaiMan It is intended, tabs are converted to 8 spaces, and it should have been the case in MRI but the tabs expansion happened after date.rb was made a native library. See the second commit for a proper diff.

If it is really a problem, I guess I could try without changing the weird indentation (mix of tabs/spaces) but it is really a pain to work with and should not be there as I just said. I mean to commit this spacing change separately.

@eregon
Copy link
Member Author

eregon commented Jul 16, 2013

See #890.

@eregon eregon closed this Jul 16, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants