문제

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.

도움이 되었습니까?

해결책

The Date#amjd method does what you're asking for, but it returns a Rational; converting to a Float gives you something easier to work with:

require 'date'

DateTime.now.amjd.to_f # => 56759.82092321331

다른 팁

require "date"
p jdate = DateTime.now.julian #=> #<DateTime: 2014-03-30T21:28:30+02:00 (...)
p jdate.julian?               # => true
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top