Recent

Author Topic: BC dates  (Read 3707 times)

Abelisto

  • Jr. Member
  • **
  • Posts: 91
BC dates
« on: December 04, 2016, 07:50:20 am »
What is the proper way to deal with BC dates? Both EncodeDate and DecodeDate functions uses Word arguments but what if my desired year is negative?
OS: Linux Mint + MATE, Compiler: FPC trunk (yes, I am risky!), IDE: Lazarus trunk

munair

  • Hero Member
  • *****
  • Posts: 887
  • compiler developer @SharpBASIC
    • SharpBASIC
Re: BC dates
« Reply #1 on: December 04, 2016, 08:02:46 am »
The best way is to use Julian Day. There are many examples on the internet how to convert Julian Day to Gregorian Date and vice-versa. You may find a ready-to-use library or you can write your own fitting your needs.
It's only logical.

Thaddy

  • Hero Member
  • *****
  • Posts: 18676
  • Jungle wars. And failing health it seems.
Re: BC dates
« Reply #2 on: December 04, 2016, 09:37:00 am »
The best way is to use Julian Day. There are many examples on the internet how to convert Julian Day to Gregorian Date and vice-versa. You may find a ready-to-use library or you can write your own fitting your needs.

Yes, use julian date.

Regarding library: No need to. Conversion functions are available as standard in /rtl/objpas/dateutil.pp
Code: Pascal  [Select][+][-]
  1.  
  2. Function DateTimeToJulianDate(const AValue: TDateTime): Double;
  3. Function JulianDateToDateTime(const AValue: Double): TDateTime;
  4. Function TryJulianDateToDateTime(const AValue: Double; out ADateTime: TDateTime): Boolean;
  5.  
  6. Function DateTimeToModifiedJulianDate(const AValue: TDateTime): Double;
  7. Function ModifiedJulianDateToDateTime(const AValue: Double): TDateTime;
  8. Function TryModifiedJulianDateToDateTime(const AValue: Double; out ADateTime: TDateTime): Boolean;
  9.  

For insight in calculations see: https://en.wikipedia.org/wiki/Julian_day
« Last Edit: December 04, 2016, 09:49:27 am by Thaddy »
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12593
  • FPC developer.
Re: BC dates
« Reply #3 on: December 04, 2016, 02:14:19 pm »
The calendar system has been changed several times over the centuries, see the calendar faq.

Even the Julian Calendar (+/- 45,46 BC?) is only slightly BC. Before that there was the (old) Roman calendar

http://www.tondering.dk/claus/calendar.html
« Last Edit: December 04, 2016, 02:16:25 pm by marcov »

munair

  • Hero Member
  • *****
  • Posts: 887
  • compiler developer @SharpBASIC
    • SharpBASIC
Re: BC dates
« Reply #4 on: December 04, 2016, 03:00:29 pm »
The calendar system has been changed several times over the centuries, see the calendar faq.

Even the Julian Calendar (+/- 45,46 BC?) is only slightly BC. Before that there was the (old) Roman calendar

http://www.tondering.dk/claus/calendar.html
Julian Dates (Julian Day count) is not a calendar. It is simply the number of days or Earth rotations counted from a specific point in time. This count can always be converted to a proleptic calendar no matter whether that calendar was in use at the time or not.

In this respect Julian Date is confusing because it has nothing to do with the calendar introduced by Julius Caesar. Joseph Scaliger who proposed the Julian Day count and to have it started in 4713 BC named it after his father Julius Scaliger. See: http://quasar.as.utexas.edu/BillInfo/JulianDatesG.html

Unfortunately, today there seems to be a consensus that Julian Date refers to the whole Julian Day number (including fractional part) whereas Julian Day refers to the integer part only. Since there is no year/month/day, the numbering should simply be called Julian Day as opposed to a Julian date of the Roman Era.
It's only logical.

 

TinyPortal © 2005-2018