using algorithms rather than tables. Julian day number calculation The Julian day number can be calculated using the following formulas (integer division rounding towards zero is used exclusively, that is, positive values are rounded down and negative values are rounded up): The months January to December are numbered 1 to 12. For the year, astronomical year numbering is used, thus 1 BC is 0, 2 BC is −1, and 4713 BC is −4712. JDN is the Julian Day Number. Use the previous day of the month if trying to find the JDN of an instant before midday UT. Converting Gregorian calendar date to Julian Day Number The algorithm is valid for all (possibly proleptic) Gregorian calendar dates after November 23, −4713. Divisions are integer divisions towards zero; fractional parts are ignored. Converting Julian calendar date to Julian Day Number The algorithm is valid for all (possibly proleptic) Julian calendar years ≥ −4712, that is, for all JDN ≥ 0. Divisions are integer divisions, fractional parts are ignored. Finding Julian date given Julian day number and time of day For the full Julian Date of a moment after 12:00 UT one can use the following. Divisions are real numbers. So, for example, January 1, 2000, at 18:00:00 UT corresponds to JD = 2451545.25 For a point in time in a given Julian day after midnight UT and before 12:00 UT, add 1 or use the JDN of the next afternoon. Finding day of week given Julian day number The US day of the week W1 (for an afternoon or evening UT) can be determined from the Julian Day Number J with the expression: If the moment in time is after midnight UT (and before 12:00 UT), then one is already in the next day of the week. The ISO day of the week W0 can be determined from the Julian Day Number J with the expression: Julian or Gregorian calendar from Julian day number This is an algorithm by Edward Graham Richards to convert a Julian Day Number, J, to a date in the Gregorian calendar (proleptic, when applicable). Richards states the algorithm is valid for Julian day numbers greater than or equal to 0. All variables are integer values, and the notation "a div b" indicates integer division, and "mod(a,b)" denotes the modulus operator. For Julian calendar: f = J + j For Gregorian calendar: f = J + j