PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: cCalendar RC 2  (Read 930 times)

Richard Kelly

  • FireFly3 Registered User
  • Senior FireFly Member
  • *
  • Posts: 318
cCalendar RC 2
« on: September 25, 2016, 12:32:43 PM »

All previous patches rolled up. The attachment now includes all presented test scripts. This release uses script4.

What's new:

1. Hebrew Calendar with rules
2. Islamic Calendar with rules
3. Persian Calendar with rules
4. Hindu Lunar Calendar with rules
5. Hindu Solar Calendar with rules
6. Coptic Calendar with rules
7. Ethiopic Calendar with rules
8. Roman Calendar without rules
9. Armenian Calendar without rules
10. Egyptian Calendar without rules
11. Bahai Calendar without rules
12. Moon Rise and Set

The Bahai calendar is the current Badi version where the start of each new year is at the moment of the spring equinox as calculated from Tehran, Iran (the birthplace of Baha’u’llah) no more than one minute past sunset. The spring equinox can shift by a day or so from year to year (March 19-22) in relation to the Gregorian calendar. It was a touchy one to get right since the solar longitude calculations are more precise than sunset in cCalendar.

I use a develop sub routine in cCalendar when I was working on it. It's a big help putting together code before actually adding a sub or function. Previously, I had removed it before uploading and have decided to leave it in there.

What's left on the agenda:

1. The Hindu date calculations need some work. There are many holidays that depend on the precise time of a lunar event.
2. Research on possibly creating some Bahai rules.
3. Some validation functions where you can present a date on a supported calendar and have it checked for correctness.
4. A few oddball things that might see the light of day as I review all my notes. It's a bit strange to read through hundreds of pages I've written up over the past 40 years about date and time to see how I've progressed with learning and my thinking has evolved.
5. Rerun all my low level test scripts and get all the function/subs called millions of times to check on any errata.
6. Review and clean up the code. I like neat, aligned and readable code. It's written in my personal style and your reading mileage may vary.
7. Create a FB project with a tabbed form that pulls everything together.
8. I've always liked reading about the Tibetan calendar and might finally put some code to it.

If you use FF, turn on your console option before running the test script.

You need to add the following since I used the Format command.

#Include Once "String.bi"

Enjoy!


Logged

Richard Kelly

  • FireFly3 Registered User
  • Senior FireFly Member
  • *
  • Posts: 318
Re: cCalendar RC 2
« Reply #1 on: September 25, 2016, 07:31:43 PM »

Update on Bahai date calculations.

I've checked the beginning of new year for the next 50 years and am in complete agreement with the rules put forth at:

http://universalhouseofjustice.bahai.org/activities-bahai-community/20140710_001

Calculation of dates based on the Bahai Badi calendar are straight forward. Birth of the Bab and Birth of Baha'u'llah which is defined as:
...We have decided that they will now be observed on the first and the second day following the occurrence of the eighth new moon after Naw-Ruz....

Validated against:

http://badipublishing.com/pdf/20141211_UHJ_50-Yr_Table_of_Dates_(English).pdf

It looks like I can build Bahai rules into cCalendar. Since Bahai days start at sunset, the Bahai day actually begins at sunset of the day before a Gregorian date.
Logged

Richard Kelly

  • FireFly3 Registered User
  • Senior FireFly Member
  • *
  • Posts: 318
Re: cCalendar RC 2
« Reply #2 on: September 26, 2016, 07:06:13 PM »

Bahai calendar patch:

Make the change below for the Era calculation.

Code: [Select]
' ========================================================================================
' Bahai Date from Serial
' ========================================================================================
Private Sub cCalendar.BahaiFromSerial (ByVal nSerial as LongInt, _
                                       ByRef uDate as BAHAI_DATE)


    uDate.Era = ((uDate.Major * 361) - 361) + ((uDate.Cycle - 1) * 19) +  uDate.Year + 1

I must have been in bubble head mode to blow such a simple calculation... :o
Logged

Richard Kelly

  • FireFly3 Registered User
  • Senior FireFly Member
  • *
  • Posts: 318
Re: cCalendar RC 2
« Reply #3 on: September 29, 2016, 01:12:41 AM »

This project has it's moments where I'm almost at a loss sometimes to figure out what's wrong.

I usually start coding a calendar with the routines that covert to a serial and convert to the calendar in question. I have a list of roughly two dozen reference dates spanning around 2,000 years that I'll test with. Then i'll take a serial date -10,000 years and loop to +10,000 years converting serial to the calendar and then back to serial. If there are any mismatches, the loop halts and spits out a bunch of intermediate values I'll use to figure out what is going on. This is where the despair almost won out. In one print statement I was out to lunch and printed the month, month, year. I spent two days tearing everything down and looking at everything thing before I noticed that typo. As a programming group, I'm sure you understand.... :-[

p.s.

The Tibetan calendar is done. I choose the Phugpa or Phukluk version used by the majority of Tibetans today.
« Last Edit: September 29, 2016, 01:16:41 AM by Richard Kelly »
Logged