Julian Date

Introduction

The Julian day-number calendar is used for historical calculations. The Julian day is the continuous count of days since the beginning of the Julian Period. The count starts from day 0 which is the day starting starting at noon on January 1, 4713 BC.

The Julian Day Number (JDN) is the integer assigned to a whole solar day in the Julian day count starting from noon Greenwich Mean Time. For example, the Julian day number for the day starting at 12:00 UT on January 1, 2000, was 2,451,545.

If you have any questions please contact us at support@interfaceware.com.

Using the Code [top]

  • Import the Julian Date channel from the Builtin: Iguana Date/Time repository
  • Experiment with the code to find out how it works
  • Then add the modules to your Translator project
  • Copy the require statement from the channel and add it at the top of your script
    Note: This module uses require to return a table
  • Adapt the code to your own requirements
  • Interactive scripting help is included for this module

This is the github code for the main module:

How it works [top]

The code uses date.parse to parse date values, and date.julian to convert them to Julian dates. It also uses the pcall() function to check for invalid dates by catching any errors from date.parse.

First we create a sample date, and then parse it with date.parse(). We use pcall() the first time we call date.parse() to catch any errors (caused by invalid dates), if we get an invalid date then we log an error. You can try this out by changing the Date = '20150903' to use an invalid date (like Date = ''this-is-not-a-date').

Inside the if statement we first use date.parse() to convert the date into the table format required by the date.julian functions:

Then we use julian.julianDayOfCurrentYear() to get the Julian day of the current year, and the string.format() function to round the result to three decimal places, both up and down.

Finally we calculate the supplied date as Julian date using julian.JDN().

More information [top]

Leave A Comment?