红宝石 |日期时间 jd()函数
DateTime#jd() :jd()是一个 DateTime 类方法,它返回一个 DateTime 对象,表示给定的儒略日数。
Syntax: DateTime.jd()
Parameter: DateTime values
Return: DateTime object denoting the given chronological Julian day number.
示例 #1:
# Ruby code for DateTime.jd() method
# loading library
require 'date'
# declaring DateTime value
date_a = DateTime.jd(25351944)
# declaring DateTime value
date_b = DateTime.jd(4678364)
# jd method
puts "DateTime jd form : #{date_a}\n\n"
puts "DateTime jd form : #{date_b}\n\n"
输出 :
DateTime jd form : 64699-03-01T00:00:00+00:00
DateTime jd form : 8096-10-27T00:00:00+00:00
示例 #2:
# Ruby code for DateTime.jd() method
# loading library
require 'date'
# declaring DateTime value
date_a = DateTime.jd(287585851944)
# declaring DateTime value
date_b = DateTime.jd(Rational('0.5'))
# jd method
puts "DateTime jd form : #{date_a}\n\n"
puts "DateTime jd form : #{date_b}\n\n"
输出 :
DateTime jd form : 787378607-01-18T00:00:00+00:00
DateTime jd form : -4712-01-01T12:00:00+00:00