Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Ruby | DateTime jd() function

  • Last Updated : 09 Jan, 2020

DateTime#jd() : jd() is a DateTime class method which returns a DateTime object denoting the given chronological Julian day number.

Syntax: DateTime.jd()

Parameter: DateTime values

Return: DateTime object denoting the given chronological Julian day number.

Example #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"

Output :

DateTime jd form : 64699-03-01T00:00:00+00:00

DateTime jd form : 8096-10-27T00:00:00+00:00

Example #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"

Output :

DateTime jd form : 787378607-01-18T00:00:00+00:00

DateTime jd form : -4712-01-01T12:00:00+00:00

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!