Anonymous
Not logged in
Talk
Contributions
Create account
Log in
Guild of Archivists
Search
Editing
D'ni time conversion
(section)
From Guild of Archivists
Namespaces
Page
Discussion
More
More
Page actions
Read
Edit
Edit source
History
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Gregorian Calendar Algorithms === The first two algorithms needed are those that convert Gregorian calendar dates to and from a version of the Julian day number. The algorithms are based on those provided by Peter Baum in an excellent [http://web.archive.org/web/20070613090550/http:/www.vsg.cape.com/~pbaum/date/date0.htm article] that gives the complete derivation of each algorithm, as well as implementation examples. The following algorithms differ from Baum's only in that the step of adding or subtracting the Julian base date of 1721118.5 is omitted, as this portion of the calculation is not needed for the purpose of Cavernian calendar conversion. The Julian Day used by these algorithms will be the number of days and fractions elapsed since midnight of the Gregorian date March 1, 0 CE. (Days are assumed to begin at the midnight that falls between the previous and current day, rather than at noon, as astronomers prefer.) No effort is made to account for leap seconds. ==== Algorithm 1. Gregorian Date to Julian Day Number ==== Assume a Gregorian date given as Day, Month, and Year, with optional time (on a 24-hour clock) given as Hour, Minute, and Second. All values are assumed to be integers. A. If the era of the date is BCE, convert the year to a CE year: <pre> Year = -(Year - 1)</pre> B. If the month is January or February, treat it as month 13 or 14 of the previous year. This step ensures that any leap days in the period fall at the end of a "year". <pre> if Month < 3 then Month = Month + 12 Year = Year - 1 end if</pre> C. Calculate the number of whole days (WD: an integer) that have elapsed. This is the number of days accounted for by the number of years that have passed, adjusted for leap days, plus the number of days accounted for by prior months in the current year, plus the day of the current month. <pre> WD = Day + FIX(((153 * Month) - 457) / 5) + INT(365.25 * Year) - INT(0.01 * Year) + INT(0.0025 * Year)</pre> D. Calculate fractional day (FD: a real number), if necessary. This is the time of day in seconds, expressed as a fraction of the total number of seconds in a day. If no time is included in the conversion, let FD = 0. <pre> FD = ((Hour * 3600) + (Minute * 60) + Second) / 86400</pre> E. Calculate Julian Day (JD: a real number) as: <pre> JD = WD + FD</pre> ==== Algorithm 2. Julian Day Number to Gregorian Date ==== Using real arithmetic, calculate Gregorian Year, Month, Day, Hour, Minute, and Second from a Julian Day (JD) that was calculated according to Algorithm 1. The input JD is assumed to be a real number. Output values are assumed to be integers. A. Extract the number of whole days and calculate the date: <pre> Z = INT(JD) G = Z - 0.25 A = INT(G / 36524.25) B = A - (0.25 * A) Year = INT((G + B) / 365.25) C = Z + B - INT(365.25 * Year) Month = FIX(((5 * C) + 456) / 153) Day = C - FIX(((153 * Month) - 457) / 5)</pre> B. If the month is 13 or 14, adjust the month and year to a January-1 starting point: <pre> if Month > 12 then Year = Year + 1 Month = Month - 12 end if</pre> C. The year is in CE form, meaning that years prior to 1 CE will be 0 or negative. To change such years to BCE form, use the calculation shown below. If this conversion is used, the program should include a variable indicating whether the date is CE or BCE. <pre> if Year < 1 then Year = 1 - Year</pre> D. If JD includes a fractional (time of day) part, extract the fraction and calculate the time: <pre> Z = (JD - INT(JD)) * 86400 Hour = FIX(Z / 3600) R = Z - (Hour * 3600) Minute = FIX(R / 60) Second = R - (Minute * 60)</pre>
Summary:
Please note that all contributions to Guild of Archivists may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
GoArch:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation
Navigation
Main Page
Random page
Categories
All pages
Recent changes
Resources
D'ni dictionary
Reference material
Utilities
Community
Forums
Jalak Game Directory
Projects
Apocrypha
Unexplored Branches
All projects
Contribute
Stubs
Wanted
Cleanup
Dead ends
Image requested
Help
Help
Guide
Policies
Wiki tools
Wiki tools
Special pages
Page values
Page tools
Page tools
User page tools
More
What links here
Related changes
Page information
Page logs