1

Date.today.jd returns a rounded number. Is there a way to get more precision in Ruby?

I want to return a Julian date for the current time in UTC.

4

2 回答 2

1

Date#amjd方法可以满足您的要求,但它返回一个 Rational;转换为 Float 可以让您更轻松地使用:

require 'date'

DateTime.now.amjd.to_f # => 56759.82092321331
于 2014-04-12T19:42:50.347 回答
0
require "date"
p jdate = DateTime.now.julian #=> #<DateTime: 2014-03-30T21:28:30+02:00 (...)
p jdate.julian?               # => true
于 2014-04-12T19:30:49.040 回答