# Visual Basic function named Julian which will compute the number of days which have elapsed since January 1, 4713 BC.

Write a Visual Basic function named Julian which will compute the number of days which have elapsed since January 1, 4713 BC.

Here is an algorithm to compute the Julian date given the month, day, and year expressed as integers:

If the year is negative, add 1 to it.

If the month is past February, add 1 to the month; otherwise, add 13 to the month and subtract 1 from the year.

Then compute

Dim lngJulDate As Long = Math.Floor(365.25 * intYear) + Math.Floor(30.6001 * intMonth) + intDay + 1720995.0

If the date was before October 15, 1582, return this value.

Otherwise, perform the following correction:

Dim intAdjustment As Integer = (0.01 * intYear)

lngJulDate = lngJulDate + 2 - intAdjustment + 0.25 * intAdjustment

Write a program which uses this function to convert a date into its corresponding Julian date.

A convenient test case is October 9, 1995 which is Julian date 2,450,000.

How would I go about getting started and how would I produce the output?

attached is a look at what the output should look like.

https://brainmass.com/computer-science/visual-basic/visual-basic-function-named-julian-which-will-compute-the-number-of-days-which-have-elapsed-since-ja-54841

#### Solution Preview

Overview - Calendars

Algorithms on this page show different ways to calculate Easter Sunday dates. It is important to understand which method, which calendar and which year range applies to each method.

The Julian calendar applies to the original calculation method from 326 AD, which was the first year a unified Easter Dating method was used. Some methods claim to work from 1 AD, which is just plain silly - Easter was not celebrated before Christ's death, and as already stated, a unified method was not used until 326 AD. The Julian calendar had fallen out of alignment in measuring solar years (keeping months aligned with seasons) well before the Gregorian calendar was introduced. Neverthess, the Julian calendar is still used today by Orthodox churches as the basis for their Easter.

The Gregorian calendar was first introduced in October 1582 in Italy, and has subsequently replaced the Julian calendar over following years in other countries. The last country to adopt the Gregorian calendar was Greece in 1923. This calendar is highly accurate, but will need a day adjustment in or shortly after 4100 AD. So Easter algorithms using the Gregorian calendar apply to years 1583 AD to 4099 AD.

Note that there is a new Easter Sunday date calculation that applies to the Gregorian calendar, but it was not necessarily adopted in all countries at the same time the Gregorian calendar was introduced. So you may need to do some research to determine how different countries implemented these changes. Of course, churches still using the Julian calendar simply convert their Julian Easter Sunday date to the equivalent date in the Gregorian calendar.

Overview - Algorithms

Is there a single definitive and correct algorithm? - YES! The algorithm based on the extraodinary research by Ron Mallen is correct for all years, using either method and the appropriate calendar. Ron's research was conducted over a period of more than 20 years, and covers aspects of astronomy, calendar history and the Easter Dating methods. You can see his Easter information at the Astonomical Society of South Australia site.

What Ron has done is to condense the approx 19 tables used in the Christian prayer books that define Easter into 5 tables that allow anyone to calculate Easter with just a calculator. This has been cross-checked with known historic dates, astronomical publications, other algorithms and various scientific references. Note that he has also discovered that many encyclopaedia and almanac definitions have heavily plagirised a wrong definition from around the mid 1970's.

To keep things well defined, I have used the following method constants in Visual Basic code below, and have included argument checking in all VB algorithms.

* method 1 is the original calculation in the Julian calendar

* method 2 is the original method with the date converted to the Gregorian calendar

* method 3 is the revised method in the Gregorian calendar

This example shows how to call the procedure EasterMallen() for the year 1999 and method 3 in Visual Basic.

' declarations (all integers)

Const EDM_JULIAN = 1

Const EDM_ORTHODOX = 2

Const EDM_WESTERN = 3

' in an event procedure ...

Dim d As Integer

Dim m As Integer

Dim y As Integer

Dim method As Integer

' get year and method from some user input

y = 1999

method = EDM_WESTERN

If EasterDate(d, m, y, method) then

' _ is a line continuation character

MsgBox "Easter in " & Format$(y) & " occurs on Sunday " _

& Format$(DateSerial(y, m, d), "Medium date"), 64

End If

All of the Visual Basic algorithms presented on this page produce the same results, although not all of them include all calculation methods. These same algorithms are shown on other pages on the internet, occasionally with errors, and often with claims of extraordinay coverage, such as 1 AD to 9999 AD. This is just nonsense - the earliest valid year for any algorithm is 326 AD in the Julian calendar, and the Gregorian calendar is valid until 4099 AD.

* Function EasterMallen() contains comments that describe Easter and how to use the correct method. It includes argument validation, and the Julian to Gregorian conversion required for method 2. This one function does it all, and returns TRUE if valid arguments were supplied, otherwise FALSE.

* Function EasterOudin() is Oudin's (1940) algorithm has been adapted by Claus Tondering, and further modified by me to include method 2 and validate the arguments. With these updates, this is also valid for all methods for all years in the appropriate calendars.

* EasterGauss() is the brilliant mathemetician Gauss' algorithm. It is correct for method 1 only, for all years ...

#### Solution Summary

Write a Visual Basic function named Julian which will compute the number of days which have elapsed since January 1, 4713 BC.