Date library using Joda-Time #882

Closed
wants to merge 2 commits into
from

Projects

None yet

2 participants

@eregon
Member
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 some commits Jul 10, 2013
@eregon eregon Trade tabs for spaces in date lib *.rb files
(MRI did remove tabs in *.rb but after date was made native)
a287414
@eregon eregon start using Joda's DateTime in lib/date.rb
* 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).
c76839b
@BanzaiMan
Member

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

@eregon
Member
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
Member
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