Skip to content

Instantly share code, notes, and snippets.

@DouglasAllen
Created March 16, 2012 01:18
Show Gist options
  • Save DouglasAllen/2048040 to your computer and use it in GitHub Desktop.
Save DouglasAllen/2048040 to your computer and use it in GitHub Desktop.
A few solutions for Date#ajd not yielding rationals for display.
require 'date'
time = Time.now.utc
puts time
year = time.year
month = time.month
day = time.day
puts DateTime.new(year, month, day).ajd * 1.0
puts DateTime.new(year, month, day).ajd / 1.0
require 'bigdecimal'
def bd(var)
return BigDecimal.new(var.to_s)
end
puts bd(DateTime.new(year, month, day).ajd) / 2.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment