Skip to content
This repository

Date library using Joda-Time #882

Closed
wants to merge 2 commits into from

2 participants

Benoit Daloze Hiro Asari
Benoit Daloze
Collaborator
eregon commented July 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.

added some commits July 10, 2013
Benoit Daloze Trade tabs for spaces in date lib *.rb files
(MRI did remove tabs in *.rb but after date was made native)
a287414
Benoit Daloze 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
Hiro Asari
Owner

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

Benoit Daloze
Collaborator
eregon commented July 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.

Benoit Daloze
Collaborator
eregon commented July 16, 2013

See #890.

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

Showing 2 unique commits by 1 author.

Jul 10, 2013
Benoit Daloze Trade tabs for spaces in date lib *.rb files
(MRI did remove tabs in *.rb but after date was made native)
a287414
Jul 13, 2013
Benoit Daloze 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
Something went wrong with that request. Please try again.