Handle Julian Dates in Ruby
I recently had to deal with parsing Julian Dates on a project. This was my first time seeing this in the wild and to my surprise, Ruby has some handy utilities on Date for converting to/from Julian Date Numbers.
Parse a Julian Date Number into a Date
Date.jd(2459936)
#=> #<Date: 2022-12-22 ((2459936j,0s,0n),+0s,2299161j)>
Convert a Date Object to a Julian Date Number
Date.new(2024, 02, 29).jd
#=> 2460370
https://en.wikipedia.org/wiki/Julian_day
Tweet