Project

General

Profile

Bug #7031

Date::mjd_to_jd disappeared

Added by Anonymous about 7 years ago. Updated about 7 years ago.

Status:
Rejected
Priority:
Normal
Target version:
-
ruby -v:
-
Backport:
[ruby-core:47549]

Description

I've migrated almost all of my Ruby code from Ruby 1.8 to 1.9 (finally!). Most things went pretty smoothly, but I recently came across a script of mine that uses Date::mjd_to_jd. This method, along with several other Date methods, seems to have disappeared from Ruby as of r31668. I didn't see any discussion of these methods in the commit logs nor could I find anything about them on the web or ruby mailing list archives. Are there replacement methods for these that I should be using instead? Was there a reason for removing these methods that I should be aware of before monkey patching them back in? Am I missing something?

Thanks,
Dave

History

Updated by drbrain (Eric Hodel) about 7 years ago

  • Category set to lib
  • Status changed from Open to Assigned
  • Assignee set to tadf (tadayoshi funaba)
  • ruby -v set to -

I believe these were not API methods

tadf, can you confirm?

Updated by david_macmahon (David MacMahon) about 7 years ago

FWIW, they were part of 1.8.7:

http://www.ruby-doc.org/stdlib-1.8.7/libdoc/date/rdoc/Date.html#method-c-mjd_to_jd

Comparing the docs for 1.8.7 and 1.9.3, it looks like all of the ::to conversion methods were dropped.

Ruby 1.8.7

$ irb -f -r date
irb(main):001:0> RUBY_VERSION
=> "1.8.7"
irb(main):002:0> Date.methods.grep /to/
=> ["jd_to_mjd", "civil_to_jd", "day_fraction_to_time", "jd_to_commercial", "ld_to_jd", "jd_to_ordinal", "time_to_day_fraction", "jd_to_civil", "zone_to_diff", "jd_to_ld", "amjd_to_ajd", "ajd_to_jd", "jd_to_wday", "ajd_to_amjd", "commercial_to_jd", "mjd_to_jd", "ordinal_to_jd", "jd_to_ajd"]

Ruby 1.9.3

$ irb -f -r date
irb(main):001:0> RUBY_VERSION
=> "1.9.3"
irb(main):002:0> Date.methods.grep /to/
=> [:respond_to_missing?]

Updated by tadf (tadayoshi funaba) about 7 years ago

  • Status changed from Assigned to Rejected
  • Priority changed from Normal to 3

is just for internal use and debugging.

try the following code.

class Date
MJD_EPOCH_IN_CJD = 2400001
def self.mjd_to_jd(mjd) mjd + MJD_EPOCH_IN_CJD end
end

Date.jd(Date::mjd_to_jd(Date.today.mjd))

Updated by david_macmahon (David MacMahon) about 7 years ago

Removing undocumented methods that have "escaped into the wild" is reasonable, but since these well documented methods escaped into the wild before Ruby 1.9, it would have been nice (IMHO) to grandfather them into Ruby 1.9. I guess it's a moot point now because I'll have to conditionally monkey patch even if they are added back. It doesn't leave a pleasant taste to have documented methods disappear without so much as a mention (AFAICT) in the ChangeLog or NEWS files. :-(

Updated by tadf (tadayoshi funaba) about 7 years ago

the latest 1.8 documentation is by William Webber.
he wanted to describe nearly all even private.
he should have respected my original documentation.

Updated by david_macmahon (David MacMahon) about 7 years ago

Well, what's done is done. One cannot put the toothpaste back in the tube. It looks like "wew" (William Webber, I presume) documented all of the non-private lib/date.rb methods in 2003 (see r4435). Prior to that it appears all undocumented and all non-nodoc. On the bright side, I have learned a couple of new "best practices" from this:

  1. Never put debug/test methods in files that end up on $LOAD_PATH. These methods can be added as needed from files that do not end up on $LOAD_PATH.

  2. Always mark "internal use" methods as private, protected, and/or nodoc as applicable.

Thanks for all your work on Ruby!!!

Updated by tadf (tadayoshi funaba) about 7 years ago

thanks for your lecture.
foolish man who doesn't know details
make me irritated.

Also available in: Atom PDF