1
Programs / CalenTools a collection of calendar stuff
« on: January 06, 2022, 07:38:59 pm »
Some of this is quite old. Some I wrote in the past couple of months.
I'm open to any comments. I know the coding is a bit simplistic and rough around the edges so to speak.
I just found out that my ASCII boxes didn't survive the copy and paste process. Oh well.
Oh, thanks to Jack for the help with the convert to Julian Day algorithm.
I'm open to any comments. I know the coding is a bit simplistic and rough around the edges so to speak.
I just found out that my ASCII boxes didn't survive the copy and paste process. Oh well.
Oh, thanks to Jack for the help with the convert to Julian Day algorithm.
Code: QB64: [Select]
- _Title "CalenTools"
- xerr = 0
- FDay$ = ""
- filenum = FreeFile
- Input #filenum, FDay$
- Close #filenum
- Main_Menu
- Sub Main_Menu
- Print "ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»"
- Print "º Main Menu º"
- Print "ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹"
- Print "º 0. CalenTools only works for years between 1583 and 3266 inclusive. º"
- Print "º See why, and read about Julian Day numbers and ISO week numbers. º"
- Print "ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ"
- Print "º 1. Add or Subtract days from a date. º"
- Print "º 2. Calendars for a month and/or a year. º"
- Print "º 3. Day of week e.g., 1968-03-17 was a Sunday. º"
- Print "º 4. Day of week repetitive e.g., what years following 1968 was 03-17 a Sunday.º"
- Print "º 5. Day of year number from date e.g., 1968-03-17 was 77th day of the year. º"
- Print "º 6. Date from day of year number e.g., in 1968 77th day was 03-17. º"
- Print "º 7. Difference between two dates in Years Months and Days. º"
- Print "º 8. Find Easter day. º"
- Print "º 9. Date to Julian Day number. º"
- Print "º A. Julian Day number to date. º"
- Print "º B. Was/is/will it be a Leap Year. º"
- Print "º c. Week number of the year (this is ISO week numbers). º"
- Print "ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ"
- Print "º Q. To Quit. You can also quit from any other prompt by entering Q. º"
- Print "ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹"
- Print "º Enter the number/letter of your choice: º"
- Print "ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ"
- Case "0": Why_Dates
- Case "1": Start_ASD
- Case "2": Start_Cals
- Case "3": Start_DoW
- Case "4": Start_DoWR
- Case "5": Start_DoY
- Case "6": Start_RDoY
- Case "7": Start_DYMD
- Case "8": Start_Easter
- Case "9": Start_Date_to_JD
- Case "a": Start_JD_to_Date
- Case "b": Start_Leap_Year
- Case "c": Start_WkNo
- Case "q": Done
- Sub Start_ASD
- Print "ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»"
- Print "ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ Add or Subtract Days ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ"
- Input " Are you Adding to or Subtracting from a date (A/S)"; q$
- OpWd$ = " plus "
- xWd$ = "add"
- yWd$ = "add to"
- OpWd$ = " minus "
- xWd$ = "subtrtact"
- yWd$ = "subtrtact from"
- Done
- Print " You must enter 'A' for adding or 'S' for subtracting."
- Input " Press 'Enter' to continue."; q$
- Start_ASD
- Date_to_YMD
- Date_to_JD
- JDs = JD
- JD = JDs + ND
- JD = JDs - ND
- JD_to_Date
- Zellers
- Day_Names_Long
- YMD_to_Str
- Print "ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ"
- Again: Start_ASD
- Sub Start_Cals
- Cals
- Get_1st_Day
- Sub Get_1st_Day
- Print "ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»"
- Print "ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ Calendars ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ"
- Print " Do you wish weeks to start on Sunday or Monday. Your choice will be"
- Print " remembered until you quit, unless you change it in the Calendar menu."
- Done
- Cals
- Get_1st_Day
- Sub Cals:
- Case "1"
- Make_Month
- Case "2"
- Print " Enter a month number between 1 and 12."
- Cals
- Make_Month
- Case "3"
- Print " Enter a 4 digit year '-' 2 digit month, e.g., yyyy-mm"
- Cals
- Print " You must enter year from 1583 to 3266 and a month from 1 - 12."
- Cals
- Make_Month
- Case "4"
- Make_Year
- Case "5"
- Print " Enter a year between 1583 and 3266."
- Cals
- Make_Year
- Case "c"
- Get_1st_Day: Cals
- Case "m"
- Main_Menu
- Case "s"
- Save_1st_Day
- Case "q"
- Done
- Cals
- Again: Start_Cals
- Sub Make_Month
- Print "ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ"
- row = 3
- col = 30
- d = 1
- Make_Cal
- Sub Make_Year
- Print "ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ"
- row = 3
- m = 1
- d = 1
- nm = m
- col = 5
- Make_Cal
- nm = nm + 1
- d = 1
- m = nm
- row = row - 8
- col = col + 25
- Next cm
- row = row + 9
- Next mr
- Sub Make_Cal
- Zellers
- n2 = dow
- Day_Of_Year
- n1 = doy: m1 = m
- m = m + 1
- n3 = 31
- Day_Of_Year: n3 = doy - n1
- m = m1
- Month_Names_Long
- row = row + 1
- row = row + 1
- dn = 0
- ' This sets up printing "Gray Days"
- DM = m1
- Days_In_Month
- GD = dlm - n2 + 1
- aGD = 1
- ' Print the calendars
- C = col
- g = 1
- wkd = 0
- s = C
- aGD = aGD + 1
- dn = dn + 1
- dn = dn + 1
- dn = dn + 1
- wkd = wkd + 1
- C = C + 3
- g = g + 1
- GD = GD + 1
- Next j
- row = row + 1
- Next i
- Sub Start_DoW
- Print "ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»"
- Print "ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ Day of Week ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ"
- Date_to_YMD
- Zellers
- Day_Names_Long
- YMD_to_Str
- Print "ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ"
- Again: Start_DoW
- Sub Start_DoWR
- Print "ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»"
- Print "ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ Day of Week Repetitive ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ"
- Date_to_YMD
- Print " Do you want to check until today or for a given number of years?"
- Input " Press 0 for today or a (positive) number up to 250 "; YrCt$
- YrCt = 250
- Zellers
- b = dow
- Print " Date Day YrNo Count"
- row = 10
- col = 23
- x = 0
- C = 0
- Zellers
- Day_Names_Short
- C = C + 1
- row = row + 1
- x = x + 1
- y = y + 1
- Print "ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ"
- Again: Start_DoWR
- Sub Start_DoY
- Print "ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»"
- Print "ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ Day of Year ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ"
- Input " Enter a date, e.g. 1969-07-20 (yyyy-mm-dd): "; Dt$
- Date_to_YMD
- Day_Of_Year
- YMD_to_Str
- Print "ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ"
- Again: Start_DoY
- Sub Start_RDoY
- Print "ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»"
- Print "ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ Reverse Day of Year ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ"
- Input " Enter year and day number, 1969-074 (yyyy-nnn): "; Dt$
- Print " You need a 4 digit year '-' 3 digit day number: yyyy-nnn."
- Start_RDoY
- Print " Enter a year between 1583 and 3266."
- Start_RDoY
- Leap_Year
- diy = 365
- diy = 366
- Print " You need day of year number between 1 and "; diy
- Start_RDoY
- d = doy + 2 - LY
- d = doy
- m = 100 * (d + 91) \ 3055
- d = d + 91 - (3055 * m \ 100)
- m = m - 2
- Zellers
- Day_Names_Long
- Month_Names_Long
- YMD_to_Str
- Print "ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ"
- Again: Start_RDoY
- Sub Start_DYMD
- Print "ÉÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍ»"
- Print "ÈÍÍÍÍÍÍÍÍÍͼ Difference Between Dates in Years, Months, and Days ÈÍÍÍÍÍÍÍÍÍÍͼ"
- Input " Enter first date (yyyy-mm-dd)"; Dt$
- Date_to_YMD
- Yr1 = y
- Mo1 = m
- Da1 = d
- Dt1$ = Dt$
- Date_to_JD
- JD1 = JD
- Input " Enter second date (yyyy-mm-dd)"; Dt$
- Date_to_YMD
- Yr2 = y
- mo2 = m
- da2 = d
- Dt2$ = Dt$
- Date_to_JD
- JD2 = JD
- ' Determine which Date/JD is larger.
- LrJD = JD1
- LrYr = Yr1
- LrMo = Mo1
- LrDa = Da1
- LrDt$ = Dt1$
- SmJD = JD2
- SmYr = Yr2
- SmMo = mo2
- SmDa = da2
- SmDt$ = Dt2$
- LrJD = JD2
- LrYr = Yr2
- LrMo = mo2
- LrDa = da2
- LrDt$ = Dt2$
- SmJD = JD1
- SmYr = Yr1
- SmMo = Mo1
- SmDa = Da1
- SmDt$ = Dt1$
- ' Find the difference between the two dates in days.
- OpJD = LrJD - SmJD
- ' Find the Days, Months, and Years between the two dates.
- ' Find Days
- OpDa = 0
- OpDa = LrDa - SmDa
- DM = LrMo
- y = LrYr
- Days_In_Month
- OpDa = LrDa + dlm - SmDa
- LrMo = LrMo - 1
- 'find Months
- OpMo = 0
- OpMo = LrMo - SmMo
- OpMo = LrMo + 12 - SmMo
- LrYr = LrYr - 1
- 'find Years
- OpYr = 0
- OpYr = LrYr - SmYr
- Print "ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ"
- Again: Start_DYMD
- Sub Start_Easter
- Print "ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»"
- Print "ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ Find Easter ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ"
- Print " Enter a year between 1583 and 3266."
- Start_RDoY
- P = (y \ 100)
- Q = ((13 + 8 * P) \ 25)
- day = (22 + d + E)
- m = 4
- d = 19
- m = 4
- d = 18
- m = 4
- d = day - 31
- m = 3
- d = day
- Month_Names_Long
- Date_to_JD
- JD = JD - 47
- JD_to_Date
- YMD_to_Str
- Month_Names_Long
- Print " And Mardi Gras was/is/will be on Tuesday, "; MoNa$; d$
- Print "ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ"
- Again: Start_Easter
- Sub Start_Date_to_JD
- Print "ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»"
- Print "ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ Date to Julian Day Number ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ"
- Date_to_YMD
- Date_to_JD
- Print "ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ"
- Again: Start_Date_to_JD
- Sub Start_JD_to_Date
- Print "ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»"
- Print "ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ Julian Day Number to Date ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ"
- Start_JD_to_Date
- JD_to_Date
- Zellers
- Day_Names_Long
- YMD_to_Str
- Print "ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ"
- Again: Start_JD_to_Date
- Sub Start_Leap_Year
- Print "ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»"
- Print "ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ Leap Year ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ"
- Print " Enter a year between 1583 and 3266."
- Start_Leap_Year
- Leap_Year
- ly$ = "Yes"
- lyw$ = "was/is/will be"
- ly$ = "No"
- lyw$ = "wasn't/isn't/won't be"
- Print "ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ"
- Again: Start_Leap_Year
- Sub Start_WkNo
- Print "ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»"
- Print "ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ Week Number ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ"
- Date_to_YMD
- Zellers
- Day_Of_Year
- WN = (10 + doy - dow) \ 7
- yy = y: y = y - 1
- mm = m: m = 1
- dd = d: d = 1
- Zellers
- Leap_Year
- WN = 53
- WN = 53
- WN = 52
- y = yy: m = mm: d = dd
- Zellers
- Day_Names_Long
- Zellers
- Day_Names_Long
- WN = 1
- y = y + 1
- Print "ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ"
- Again: Start_WkNo
- ' ================================================================================
- ' common SUBs used by other routines
- ' ================================================================================
- Sub Again
- Dt$ = ""
- y = 0
- m = 0
- d = 0
- JD = 0
- row = CsrLin
- Main_Menu
- Done
- ' Gives the day of week for any Gregorian calendar date.
- Sub Zellers
- mz = m - 2: yz = y
- mz = m + 10: yz = y - 1
- cz = yz \ 100: dz = yz - 100 * cz
- dow = ((13 * mz - 1) \ 5) + d + dz + (dz \ 4) + (cz \ 4) - cz - cz + 77
- dow = dow - 7 * (dow \ 7)
- ' Gives the day of the year
- Sub Day_Of_Year
- doy = (3055 * (m + 2) \ 100) - 91
- Leap_Year
- doy = doy + d
- Sub Leap_Year
- LY = 0
- ' Get the number of days for last month (dlm), this month (dtm), and next month (dnm)
- Sub Days_In_Month
- Leap_Year
- DM1 = DM * 2 - 1
- ' Convert a Gregorian Date to a Julian Day number.
- Sub Date_to_JD
- JD = d - 32075 + (1461 * (y + 4800 + ((m - 14) \ 12)) \ 4) + 367 * (m - 2 - ((m - 14) \ 12) * 12) \ 12 - 3 * ((y + 4900 + ((m - 14) \ 12)) \ 100) \ 4
- ' Convert a Julian Day number to a Gregorian Date.
- Sub JD_to_Date
- L = JD + 68569
- n = 4 * L \ 146097
- L = L - (146097 * n + 3) \ 4
- y = 4000 * (L + 1) \ 1461001
- L = L - (1461 * y \ 4) + 31
- m = 80 * L \ 2447
- d = L - (2447 * m \ 80)
- L = m \ 11
- m = m + 2 - (12 * L)
- y = 100 * (n - 49) + y + L
- Sub Day_Names_Short
- Sub Day_Names_Long
- Sub Month_Names_Short
- Sub Month_Names_Long
- ' Convert input date (Dt$) to year, month, and day integers And check that they are valid
- Sub Date_to_YMD
- DM = m
- Days_In_Month
- Print " Your date has too few or too many characters in it."
- xerr = 1
- Print " Enter a year between 1583 and 3266."
- xerr = 1
- Print " Enter a month number between 1 and 12."
- xerr = 1
- Print " Enter a day number between 1 and "; dtm;
- xerr = 1
- ' Convert Year, month, and day integers to strings and add leading 0s to digits less than 10
- Sub YMD_to_Str
- Sub Why_Dates
- Print "ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ"
- Print " CalenTools will not work with years prior to 1583 or after 3266, this was"
- Print " done intentionally partly as an error prevention measure."
- Print " Prior to 1583 most of the western world used the Julian Calendar which had"
- Print " an extra 3 leap years every 400 years. Pope Gregory XIII wrote a papal bull"
- Print " in Feb. 1582 to correct for this error by suppressing 10 days. Thus causing"
- Print " Oct. 5, 1582 to become Oct. 15, 1582. (So I dropped the last two and a half"
- Print " months of 1582 because and I don't think most people will need them)."
- Print " The papel bull was adopted by most countries at different times. A lof of"
- Print " Roman Catholic countries Spain, Portugal, etc. and their colonies changed on"
- Print " Oct. 15, 1582. Great Britain and the American colonies changed in 1752. The"
- Print " most recant change from The Julian calendar that I know of is Turkey in 1927."
- Print " As Far as I know only a few religions still use the Julian calendar. You"
- Print " can use the search engine of your choice to find a list of when the different"
- Print " countries adopted the Gregorian calendar."
- Print " As for after 3266, it my be my limited sense of reality, but I don't really"
- Print " think it's necessary as I think there will be something better by then. Maybe"
- Print " even a whole new calendar system. "
- Print " Also it's the end of the first Julian Period so Julian Day numbers will"
- Print " restart at one. I'm using Julian Day numbers are here to 'Add or Subtract"
- Print " Days' and to find the 'Difference between two dates'."
- Print " The Julian Period and Julian Day numbers (not to be confused with the"
- Print " Julian Calendar) start at noon on -4712-01-01 of the Julian calendar (or"
- Print " -4713-11-24 Gregorian Calendar). This is because in 4713 BC the 'Indiction'"
- Print " (15 yrs.), the 'Golden Number' (19) and the 'Solar Number' (28 yrs.) were all"
- Print " one. The Julian Period is 7980 years long. The next time this happens is"
- Print " Jan. 01, 3268 Julian calendar or Nov. 24, 3267 Gregorian calendar."
- Print "ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ"
- Print " The ISO (International Organization for Standardization) week starts on"
- Print " Mon. The 1st week of the year has Jan. 4th and the first Thu. of the year in"
- Print " it. If Jan. the 1st is a Thu., making Sun. the 4th the last day of the week,"
- Print " the first day of the first week is Mon. Dec. 29th of the previous year. If"
- Print " Jan. 4th is a Mon. then Jan. 1st is Fri. of the last week of the previous year."
- Print " Also a year that starts on Thu. (or Wed. if a leap year) has 53 weeks"
- Print " because there are 53 Thu. in the year and therefore 53 continuous weeks that"
- Print " each have at least 4 days of the current calendar year per week. Therefore,"
- Print " Fri. Jan. 1st 2016 is Fri. of the 53rd week of 2015."
- Print " There are 71 of these 53 week years every 400 years."
- Print "ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ"
- Done
- Main_Menu
- Sub Save_1st_Day
- Print "ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ"
- Print " Saving this will create a 3 byte file on your hard drive. This file will"
- Print " waste a lot of space. Depending on drive size and operating system you are"
- Print " wasting, on average, between 509 to 4093 bytes. Just to save you from having"
- Print " to press 's' or 'm' every time you view calendars in CalenTools."
- Print " The file it creates will be in the same directory that you have CalenTools in."
- Print " So if you have it on the desktop you will end up with two CalenTools files on"
- Print " your desktop. Also if for whatever reason you happen to have a file named"
- Print " 'calentools.dat' in the same directory it will be over written."
- Input " Do you wish to continue (Y/N)"; q$
- Done
- Cals
- Do_Save
- Save_1st_Day
- Sub Do_Save
- fd$ = FDay$ 'This is in case you are using Sun. but want to save Mon.
- Input " Do you want the week to start on Sunday or Monday (S/M)"; q$
- FDay$ = q$
- filenum = FreeFile
- Print #filenum, FDay$
- Close #filenum
- FDay$ = fd$
- Cals
- Sub Done