Author | Topic: Calender conversion | |
---|---|---|
Jan Escholt | Calender conversion on Sat, 19 Jan 2019 13:52:14 +0100 Hello, has anyone ever done the conversion of julian to gregorian calendar and vice versa in Xbase ++? I need the full support, starting from 1582. There are more simple formulas, but these all start much later. Jan | |
Peter Alderliesten | Re: Calender conversion on Mon, 21 Jan 2019 09:42:43 +0100 Jan, > has anyone ever done the conversion of julian to gregorian calendar and > vice versa in Xbase ++? > > I need the full support, starting from 1582. There are more simple > formulas, but these all start much later. What about the JtoD and DtoJ functions? Don't they work properly? Peter | |
Jan Escholt | Re: Calender conversion on Mon, 21 Jan 2019 21:31:17 +0100 Peter, unfortunately not. These function work with the Julian Date, not the Julian Caendar. Very different stuff. Jan Am 21.01.2019 um 09:42 schrieb Peter Alderliesten: > Jan, > >> has anyone ever done the conversion of julian to gregorian calendar and >> vice versa in Xbase ++? >> >> I need the full support, starting from 1582. There are more simple >> formulas, but these all start much later. > > What about the JtoD and DtoJ functions? > Don't they work properly? > > Peter > | |
Peter Alderliesten | Re: Calender conversion on Mon, 21 Jan 2019 22:30:16 +0100 Jan, Does this help you? http://www.drdobbs.com/cpp/julian-and-gregorian-calendars/184408959 Peter | |
Andreas Gehrs-Pahl | Re: Calender conversion on Tue, 22 Jan 2019 02:38:38 -0500 Jan, Peter wrote: >>What about the JtoD and DtoJ functions? >>Don't they work properly? and you responded: >unfortunately not. These function work with the Julian Date, not the >Julian Caendar. Very different stuff. This conflicts with your original request: >I need the full support, starting from 1582. There are more simple >formulas, but these all start much later. The Julian Calendar was introduced in 46 BC (Before Christ) and started on January 1, 45 BC (which was also 709 AUC (Ab Urbe Condita)). The calendar we currently use, the Georgian Calendar, started on October 5, 1582 AD (Anno Domini) (in the Julian Calendar), which was October 15, 1582 AD (in the Georgian Calendar). The dates between October 4 and October 15, 1582 AD were skipped by the Georgian Calendar. But the Julian Calendar was still used in many countries for many years after that start date, for example until September 1752 in Britain and even until 1926 in Turkey. The Julian Day number (sometimes also called a Julian Date) simply counts the days (and fractions thereof) that have elapsed since January 1, 4713 BC. The Xbase++ functions DtoJ() and JtoD() are only valid for the Gregorian Calendar Dates, which makes any Julian Day/Date value prior to October 15, 1582 AD incorrect (or at least not useful for conversions). Any Julian Day number less than 2299161 will give "Proleptic Gregorian" dates, rather than the more commonly used Julian Calendar dates, which can differ by several days and might even be in a different year. Because the Julian Calendar was still used AFTER the Gregorian Calendar was introduced, it might be useful to convert between those two calendars for dates AFTER October 5, 1582 AD (Julian). The formula for this is pretty simply, but a Julian Date Year didn't start everywhere and always on January 1 (like it does with the Gregorian Calendar), but could start on all kinds of other days during the year, similar to the Fiscal Year in the USA, which currently starts on October 1 of the previous Calendar Year. So, in Britain e.g., February 10, 1750 AD (Julian) was actually February 21, 1751 AD (Gregorian), as the British (legal) year didn't start until March 25 (of the following Calendar Year). Also keep in mind that the Gregorian Calendar (which Xbase++ uses) doesn't contain some dates that exist(ed) in the Julian Calendar, like February 29 in the years 1700, 1800, and 1900. So you can't use Date values for (all) Julian Calendar Date values. Instead, a character string would have to be used for (at least) those dates. I can't think of any practical use for trying to convert Gregorian Calendar dates to Julian Calendar dates, especially when the (correct) Year might depend on the location where that Julian Date was (or would have been) used. Nevertheless, below is a (relatively) simple formula to determine the basic (text format) Julian Calendar date (from a given Gregorian Calendar date). Function Julian_Calendar(dDate) LOCAL cRemark := '' LOCAL nJulian := DtoJ(dDate) LOCAL nYear := Year(dDate) LOCAL nMonth := Month(dDate) LOCAL nDay := Day(dDate) LOCAL n100_LY := (nYear / 100) LOCAL n400_LY := (nYear / 400) LOCAL nDiff := int(n100_LY) - int(n400_LY) - 2 LOCAL lNoLeap := (n100_LY == int(n100_LY) .and. n400_LY <> int(n400_LY)) LOCAL dJulian := JtoD(nJulian - nDiff) LOCAL nJYear := Year(dJulian) LOCAL nJMonth := Month(dJulian) LOCAL nJDay := Day(dJulian) if lNoLeap if nMonth < 3 .or. nJMonth < 3 dJulian += 1 nJMonth := Month(dJulian) nJDay := Day(dJulian) if nJMonth == 3 .and. nJDay == 1 dJulian -= 1 ; nJMonth := 2 ; nJDay := 29 cRemark := ' (not a valid Xbase++ Date Value!)' endif endif endif return (CMonth(dJulian) + ' ' + alltrim(str(nJDay)) + ', ' + ; StrZero(nJYear, 4) + cRemark) Hope that helps, Andreas Andreas Gehrs-Pahl Absolute Software, LLC phone: (989) 723-9927 email: Andreas@AbsoluteSoftwareLLC.com web: http://www.AbsoluteSoftwareLLC.com [F]: https://www.facebook.com/AbsoluteSoftwareLLC | |
Andreas Gehrs-Pahl | Re: Calender conversion on Tue, 22 Jan 2019 02:51:08 -0500 There were several instances in my posts where "Gregorian" Calendar was misspelled as "Georgian" Calendar. I blame it on the Spell Checker... Andreas Andreas Gehrs-Pahl Absolute Software, LLC phone: (989) 723-9927 email: Andreas@AbsoluteSoftwareLLC.com web: http://www.AbsoluteSoftwareLLC.com [F]: https://www.facebook.com/AbsoluteSoftwareLLC |