Julian Day Calculator API - Ruby Gem

Julian Day Calculator converts between Gregorian calendar dates and Julian Day Numbers (JDN). Julian Day is a continuous count of days used in astronomy and historical research.

Installation

Add this line to your application's Gemfile:

gem 'apiverve_julianday'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install apiverve_julianday

Getting Started

Get your API key at APIVerve

Basic Usage

require 'apiverve_julianday'

# Initialize the client
client = APIVerve::Julianday::Client.new(api_key: "YOUR_API_KEY")

# Make a request
response = client.execute({ date: "2024-03-15" })

# Print the response
puts response

Error Handling

begin
  response = client.execute({ date: "2024-03-15" })
  puts response["data"]
rescue APIVerve::Julianday::ValidationError => e
  puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Julianday::APIError => e
  puts "API error: #{e.message}"
  puts "Status code: #{e.status_code}"
end

Debug Mode

# Enable debug logging
client = APIVerve::Julianday::Client.new(
  api_key: "YOUR_API_KEY",
  debug: true
)

Example Response

{
  "status": "ok",
  "error": null,
  "data": {
    "gregorian": "2024-03-15",
    "julianDayNumber": 2460385,
    "modifiedJulianDate": 60384.5,
    "dayOfWeek": "Friday",
    "weekNumber": 11,
    "dayOfYear": 75,
    "daysFromToday": -340
  }
}

Documentation

For more information, visit the API Documentation.

Support

License

This gem is available under the MIT License.