Lat_Long Lat, Lon, 0 'get latitude and longitude, but no need to force them to redownload over and over,
' if we already have them saved on the disk.
SunStuff Lat, Lon, ThisMonth, Today, ThisYear
GetHolidays ThisYear
TitleScreen
update = -1
CurrentMonth = ThisMonth
CurrentDay = Today
Currentyear = ThisYear
reload: 'load our background
'We store 12 set backgrounds before and after our current month, which don't change.
'But if we go any further than that, then we just use random backgrounds for extreme future events.
'This is to give an impression of stability for most usage.
'For example, I start up with an image of the moon on the screen for my current month.
'I then scroll a few screens to see what is coming up in a few months, and then want to scroll back.
'All I have to do is look for that visual cue of the image of the moon on my screen, as a quick reference guide.
t$
= ".\Backgrounds\" + _TRIM$(STR$(BackGrounds
(bg
))) + ".jpg" IF t1
= -1 THEN 'if this is a bad background, then load a different one redo:
IF BackGrounds
(j
) = t
GOTO redo
BackGrounds(i) = t
'But after a dozen months or so? No need to keep those image handles in memory. Just toss them,
'as my poor memory couldn't store that much information anyway. :P
CenterMonth CurrentMonth, Currentyear
DrawDays CurrentMonth, Currentyear
ShowDailyStuff Lat, Lon
update = 0
CurrentMonth = CurrentMonth - 1
IF CurrentMonth
< 1 THEN CurrentMonth
= 12: Currentyear
= Currentyear
- 1 bg = bg - 1
update = -1
CurrentMonth = CurrentMonth + 1
IF CurrentMonth
> 12 THEN CurrentMonth
= 1: Currentyear
= Currentyear
+ 1 bg = bg + 1
update = -1
LINE (1320, 50)-(1560, 500), Gold
, BF
cp = 1280 + (1600 - 1280) \ 2 'center of our non-calendar area
t$
= "For Lat/Long:" + STR$(INT(100 * Lat
) / 100) + "," + STR$(INT(100 * Lon
) / 100) _PRINTSTRING (1325, 228), "Moon Phase: " + MoonPhase$
(month
, day
, year
)
text$ = "Steve's Calendar"
GetBackgrounds
text$ = "Press <ANY KEY> to continue."
IF _FILEEXISTS("Holidays.txt") = 0 THEN 'if the file doesn't exist, then create it with our default data PRINT #f1
, "Holidays are stored in the format: MONTH, Modifier, Day, Name" PRINT #f1
, "01, ON, 01, New Years Day" PRINT #f1
, "01, ON, 06, Epiphany" PRINT #f1
, "01, ON, 07, Orthodox Christmas Day" PRINT #f1
, "01, ON, 13, Stephen Foster Memorial Day" PRINT #f1
, "01, ON, 14, Orthodox New Year" PRINT #f1
, "01, THIRD, Monday, Martin Luther King Day" PRINT #f1
, "02, ON, 01, National Freedom Day" PRINT #f1
, "02, ON, 01, Start of Black History Month" PRINT #f1
, "02, ON, 02, Groundhog's Day" PRINT #f1
, "02, FIRST, Sunday, Super Bowl" PRINT #f1
, "02, ON, 12, Lincoln's Birthday" PRINT #f1
, "02, ON, 14, Valentine's Day" PRINT #f1
, "02, THIRD, Monday, President's Day" PRINT #f1
, "03, ON, 01, Start of Women's History Month" PRINT #f1
, "03, SECOND, Sunday, Start of Daylight Saving's Time" PRINT #f1
, "03, ON, 17, Saint Patrick's Day" PRINT #f1
, "03, ON, 29, National Vietnam War Vetern's Day" PRINT #f1
, "05, SECOND, Sunday, Mother's Day" PRINT #f1
, "05, LAST, Monday, Memorial Day" PRINT #f1
, "06, THIRD, Sunday, Father's Day" PRINT #f1
, "07, ON, 04, Independence Day" PRINT #f1
, "07, ON, 15, Tax Day" PRINT #f1
, "09, FIRST, Monday, Labor Day" PRINT #f1
, "09, ON, 25, Steve McNeill's Birthday" PRINT #f1
, "10, ON, 31, Halloween" PRINT #f1
, "11, ON, 01, All Saint's Day" PRINT #f1
, "11, FIRST, Sunday, End of Daylight Saving's Time" PRINT #f1
, "11, ON, 02, All Soul's Day" PRINT #f1
, "11, ON, 11, Vetern's Day" PRINT #f1
, "11, FOURTH, Thursday, Thanksgiving" PRINT #f1
, "12, ON, 07, Pearl Harbor Remembrance Day" PRINT #f1
, "12, ON, 24, Christmas Eve" PRINT #f1
, "12, ON, 25, Christmas Day" PRINT #f1
, "12, ON, 31, New Year's Eve" LINE INPUT #f1
, junk$
'first line is file comment and not related to the data ' PRINT month, event$, day$, nam$
count = count + 1
HolidayList(count).month = month
HolidayList
(count
).day
= VAL(day$
) ELSEIF RIGHT$(event$
, 4) = "LAST" THEN 'we need to count backwards to find the last target day d = ConvertDayToNum(day$)
FOR i
= NumberOfDays
(month
, year
) TO 1 STEP -1 CASE "LAST": HolidayList
(count
).day
= i
CASE "SECOND TO LAST": HolidayList
(count
).day
= i
- 7 CASE "THIRD TO LAST": HolidayList
(count
).day
= i
- 14 CASE "FOURTH TO LAST": HolidayList
(count
).day
= i
- 21 CASE "FIFTH TO LAST": HolidayList
(count
).day
= i
- 28 d = ConvertDayToNum(day$)
FOR i
= 1 TO NumberOfDays
(month
, year
) CASE "FIRST": HolidayList
(count
).day
= i
CASE "SECOND": HolidayList
(count
).day
= i
+ 7 CASE "THIRD": HolidayList
(count
).day
= i
+ 14 CASE "FOURTH": HolidayList
(count
).day
= i
+ 21 CASE "FIFTH": HolidayList
(count
).day
= i
+ 28 HolidayList
(count
).
name = nam$
'*******************************************************************
'** Special Exceptions for days which are hard to calculate otherwise
'*******************************************************************
IF HolidayList
(count
).
name = "Thanksgiving" THEN 'Add Black Friday and Cyber Monday d = HolidayList(count).day
count = count + 2
HolidayList(count - 1).month = 11
HolidayList(count - 1).day = d + 1
HolidayList
(count
- 1).
name = "Black Fridy" d = HolidayList(count - 1).day + 4
HolidayList(count).month = 11
IF d
> 30 THEN d
= d
- 30: HolidayList
(count
).month
= 12 HolidayList(count).day = d
HolidayList
(count
).
name = "Cyber Monday"
'*******************************************************************
'** Seasons, which are on a simple look-up table
'*******************************************************************
PRINT #f1
, "2016, 20, Mar, 04:30 GMT, 20, Jun, 23:34 BST, 22, Sep, 15:21 BST, 21, Dec, 10:44 GMT" PRINT #f1
, "2017, 20, Mar, 10:29 GMT, 21, Jun, 05:24 BST, 22, Sep, 21:02 BST, 21, Dec, 16:28 GMT" PRINT #f1
, "2018, 20, Mar, 16:15 GMT, 21, Jun, 11:07 BST, 23, Sep, 02:54 BST, 21, Dec, 22:23 GMT" PRINT #f1
, "2019, 20, Mar, 21:59 GMT, 21, Jun, 16:54 BST, 23, Sep, 08:50 BST, 22, Dec, 04:19 GMT" PRINT #f1
, "2020, 20, Mar, 03:50 GMT, 20, Jun, 22:44 BST, 22, Sep, 14:31 BST, 21, Dec, 10:02 GMT" PRINT #f1
, "2021, 20, Mar, 09:37 GMT, 21, Jun, 04:32 BST, 22, Sep, 20:21 BST, 21, Dec, 15:59 GMT" PRINT #f1
, "2022, 20, Mar, 15:33 GMT, 21, Jun, 10:14 BST, 23, Sep, 02:04 BST, 21, Dec, 21:48 GMT" PRINT #f1
, "2023, 20, Mar, 21:24 GMT, 21, Jun, 15:58 BST, 23, Sep, 07:50 BST, 22, Dec, 03:27 GMT" PRINT #f1
, "2024, 20, Mar, 03:06 GMT, 20, Jun, 21:51 BST, 22, Sep, 13:43 BST, 21, Dec, 09:20 GMT" PRINT #f1
, "2025, 20, Mar, 09:01 GMT, 21, Jun, 03:42 BST, 22, Sep, 19:19 BST, 21, Dec, 15:03 GMT" PRINT #f1
, "2026, 20, Mar, 14:46 GMT, 21, Jun, 09:24 BST, 23, Sep, 01:05 BST, 21, Dec, 20:50 GMT" PRINT #f1
, "2027, 20, Mar, 20:25 GMT, 21, Jun, 15:11 BST, 23, Sep, 07:02 BST, 22, Dec, 02:42 GMT" PRINT #f1
, "2028, 20, Mar, 02:17 GMT, 20, Jun, 21:02 BST, 22, Sep, 12:45 BST, 21, Dec, 08:20 GMT" PRINT #f1
, "2029, 20, Mar, 08:02 GMT, 21, Jun, 02:48 BST, 22, Sep, 18:38 BST, 21, Dec, 14:14 GMT" PRINT #f1
, "2030, 20, Mar, 13:52 GMT, 21, Jun, 08:31 BST, 23, Sep, 00:27 BST, 21, Dec, 20:09 GMT" PRINT #f1
, "2031, 20, Mar, 19:41 GMT, 21, Jun, 14:17 BST, 23, Sep, 06:15 BST, 22, Dec, 01:55 GMT" PRINT #f1
, "2032, 20, Mar, 01:22 GMT, 20, Jun, 20:09 BST, 22, Sep, 12:11 BST, 21, Dec, 07:56 GMT" PRINT #f1
, "2033, 20, Mar, 07:23 GMT, 21, Jun, 02:01 BST, 22, Sep, 17:51 BST, 21, Dec, 13:46 GMT" PRINT #f1
, "2034, 20, Mar, 13:17 GMT, 21, Jun, 07:44 BST, 22, Sep, 23:39 BST, 21, Dec, 19:34 GMT" PRINT #f1
, "2035, 20, Mar, 19:02 GMT, 21, Jun, 13:33 BST, 23, Sep, 05:39 BST, 22, Dec, 01:31 GMT" PRINT #f1
, "2036, 20, Mar, 01:03 GMT, 20, Jun, 19:32 BST, 22, Sep, 11:23 BST, 21, Dec, 07:13 GMT" PRINT #f1
, "2037, 20, Mar, 06:50 GMT, 21, Jun, 01:22 BST, 22, Sep, 17:13 BST, 21, Dec, 13:08 GMT" PRINT #f1
, "2038, 20, Mar, 12:41 GMT, 21, Jun, 07:09 BST, 22, Sep, 23:02 BST, 21, Dec, 19:02 GMT" PRINT #f1
, "2039, 20, Mar, 18:32 GMT, 21, Jun, 12:57 BST, 23, Sep, 04:49 BST, 22, Dec, 00:40 GMT" PRINT #f1
, "2040, 20, Mar, 00:11 GMT, 20, Jun, 18:46 BST, 22, Sep, 10:45 BST, 21, Dec, 06:33 GMT" PRINT #f1
, "2041, 20, Mar, 06:07 GMT, 21, Jun, 00:36 BST, 22, Sep, 16:26 BST, 21, Dec, 12:18 GMT" PRINT #f1
, "2042, 20, Mar, 11:53 GMT, 21, Jun, 06:16 BST, 22, Sep, 22:11 BST, 21, Dec, 18:04 GMT" PRINT #f1
, "2043, 20, Mar, 17:28 GMT, 21, Jun, 11:58 BST, 23, Sep, 04:07 BST, 22, Dec, 00:01 GMT" PRINT #f1
, "2044, 19, Mar, 23:20 GMT, 20, Jun, 17:51 BST, 22, Sep, 09:48 BST, 21, Dec, 05:43 GMT" PRINT #f1
, "2045, 20, Mar, 05:07 GMT, 20, Jun, 23:34 BST, 22, Sep, 15:33 BST, 21, Dec, 11:35 GMT" PRINT #f1
, "2046, 20, Mar, 10:58 GMT, 21, Jun, 05:14 BST, 22, Sep, 21:21 BST, 21, Dec, 17:28 GMT" PRINT #f1
, "2047, 20, Mar, 16:52 GMT, 21, Jun, 11:03 BST, 23, Sep, 03:08 BST, 21, Dec, 23:07 GMT" PRINT #f1
, "2048, 19, Mar, 22:34 GMT, 20, Jun, 16:54 BST, 22, Sep, 09:00 BST, 21, Dec, 05:02 GMT" PRINT #f1
, "2049, 20, Mar, 04:28 GMT, 20, Jun, 22:47 BST, 22, Sep, 14:42 BST, 21, Dec, 10:52 GMT" PRINT #f1
, "2050, 20, Mar, 10:19 GMT, 21, Jun, 04:33 BST, 22, Sep, 20:28 BST, 21, Dec, 16:38 GMT" PRINT #f1
, "2051, 20, Mar, 15:59 GMT, 21, Jun, 10:18 BST, 23, Sep, 02:27 BST, 21, Dec, 22:34 GMT" PRINT #f1
, "2052, 19, Mar, 21:56 GMT, 20, Jun, 16:16 BST, 22, Sep, 08:15 BST, 21, Dec, 04:17 GMT" PRINT #f1
, "2053, 20, Mar, 03:47 GMT, 20, Jun, 22:04 BST, 22, Sep, 14:06 BST, 21, Dec, 10:10 GMT" PRINT #f1
, "2054, 20, Mar, 09:34 GMT, 21, Jun, 03:47 BST, 22, Sep, 19:59 BST, 21, Dec, 16:10 GMT" PRINT #f1
, "2055, 20, Mar, 15:28 GMT, 21, Jun, 09:40 BST, 23, Sep, 01:48 BST, 21, Dec, 21:55 GMT" PRINT #f1
, "2056, 19, Mar, 21:11 GMT, 20, Jun, 15:28 BST, 22, Sep, 07:39 BST, 21, Dec, 03:51 GMT" PRINT #f1
, "2057, 20, Mar, 03:08 GMT, 20, Jun, 21:19 BST, 22, Sep, 13:23 BST, 21, Dec, 09:43 GMT" PRINT #f1
, "2058, 20, Mar, 09:05 GMT, 21, Jun, 03:04 BST, 22, Sep, 19:08 BST, 21, Dec, 15:25 GMT" PRINT #f1
, "2059, 20, Mar, 14:44 GMT, 21, Jun, 08:47 BST, 23, Sep, 01:03 BST, 21, Dec, 21:18 GMT" PRINT #f1
, "2060, 19, Mar, 20:38 GMT, 20, Jun, 14:45 BST, 22, Sep, 06:48 BST, 21, Dec, 03:01 GMT" PRINT #f1
, "2061, 20, Mar, 02:26 GMT, 20, Jun, 20:32 BST, 22, Sep, 12:31 BST, 21, Dec, 08:49 GMT" PRINT #f1
, "2062, 20, Mar, 08:07 GMT, 21, Jun, 02:11 BST, 22, Sep, 18:20 BST, 21, Dec, 14:42 GMT" PRINT #f1
, "2063, 20, Mar, 13:59 GMT, 21, Jun, 08:02 BST, 23, Sep, 00:08 BST, 21, Dec, 20:21 GMT" PRINT #f1
, "2064, 19, Mar, 19:38 GMT, 20, Jun, 13:45 BST, 22, Sep, 05:57 BST, 21, Dec, 02:09 GMT" PRINT #f1
, "2065, 20, Mar, 01:28 GMT, 20, Jun, 19:32 BST, 22, Sep, 11:42 BST, 21, Dec, 08:00 GMT" PRINT #f1
, "2066, 20, Mar, 07:20 GMT, 21, Jun, 01:16 BST, 22, Sep, 17:27 BST, 21, Dec, 13:45 GMT" PRINT #f1
, "2067, 20, Mar, 12:53 GMT, 21, Jun, 06:56 BST, 22, Sep, 23:19 BST, 21, Dec, 19:43 GMT" PRINT #f1
, "2068, 19, Mar, 18:49 GMT, 20, Jun, 12:53 BST, 22, Sep, 05:07 BST, 21, Dec, 01:32 GMT" PRINT #f1
, "2069, 20, Mar, 00:45 GMT, 20, Jun, 18:41 BST, 22, Sep, 10:51 BST, 21, Dec, 07:22 GMT" PRINT #f1
, "2070, 20, Mar, 06:34 GMT, 21, Jun, 00:22 BST, 22, Sep, 16:45 BST, 21, Dec, 13:19 GMT" PRINT #f1
, "2071, 20, Mar, 12:34 GMT, 21, Jun, 06:21 BST, 22, Sep, 22:37 BST, 21, Dec, 19:04 GMT" PRINT #f1
, "2072, 19, Mar, 18:21 GMT, 20, Jun, 12:13 BST, 22, Sep, 04:27 BST, 21, Dec, 00:56 GMT" PRINT #f1
, "2073, 20, Mar, 00:13 GMT, 20, Jun, 18:07 BST, 22, Sep, 10:15 BST, 21, Dec, 06:50 GMT" PRINT #f1
, "2074, 20, Mar, 06:09 GMT, 20, Jun, 23:58 BST, 22, Sep, 16:03 BST, 21, Dec, 12:35 GMT" PRINT #f1
, "2075, 20, Mar, 11:46 GMT, 21, Jun, 05:40 BST, 22, Sep, 21:59 BST, 21, Dec, 18:27 GMT" PRINT #f1
, "2076, 19, Mar, 17:39 GMT, 20, Jun, 11:36 BST, 22, Sep, 03:50 BST, 21, Dec, 00:13 GMT" PRINT #f1
, "2077, 19, Mar, 23:31 GMT, 20, Jun, 17:23 BST, 22, Sep, 09:36 BST, 21, Dec, 06:01 GMT" PRINT #f1
, "2078, 20, Mar, 05:11 GMT, 20, Jun, 22:58 BST, 22, Sep, 15:24 BST, 21, Dec, 11:58 GMT" PRINT #f1
, "2079, 20, Mar, 11:00 GMT, 21, Jun, 04:49 BST, 22, Sep, 21:13 BST, 21, Dec, 17:44 GMT" PRINT #f1
, "2080, 19, Mar, 16:44 GMT, 20, Jun, 10:34 BST, 22, Sep, 02:56 BST, 20, Dec, 23:33 GMT" PRINT #f1
, "2081, 19, Mar, 22:34 GMT, 20, Jun, 16:16 BST, 22, Sep, 08:37 BST, 21, Dec, 05:22 GMT" PRINT #f1
, "2082, 20, Mar, 04:30 GMT, 20, Jun, 22:03 BST, 22, Sep, 14:23 BST, 21, Dec, 11:04 GMT" PRINT #f1
, "2083, 20, Mar, 10:10 GMT, 21, Jun, 03:44 BST, 22, Sep, 20:11 BST, 21, Dec, 16:53 GMT" PRINT #f1
, "2084, 19, Mar, 15:59 GMT, 20, Jun, 09:40 BST, 22, Sep, 01:59 BST, 20, Dec, 22:41 GMT" PRINT #f1
, "2085, 19, Mar, 21:53 GMT, 20, Jun, 15:33 BST, 22, Sep, 07:43 BST, 21, Dec, 04:28 GMT" PRINT #f1
, "2086, 20, Mar, 03:35 GMT, 20, Jun, 21:09 BST, 22, Sep, 13:32 BST, 21, Dec, 10:22 GMT" PRINT #f1
, "2087, 20, Mar, 09:28 GMT, 21, Jun, 03:06 BST, 22, Sep, 19:28 BST, 21, Dec, 16:08 GMT" PRINT #f1
, "2088, 19, Mar, 15:17 GMT, 20, Jun, 08:56 BST, 22, Sep, 01:18 BST, 20, Dec, 21:56 GMT" PRINT #f1
, "2089, 19, Mar, 21:06 GMT, 20, Jun, 14:43 BST, 22, Sep, 07:07 BST, 21, Dec, 03:52 GMT" PRINT #f1
, "2090, 20, Mar, 03:02 GMT, 20, Jun, 20:36 BST, 22, Sep, 12:59 BST, 21, Dec, 09:43 GMT" PRINT #f1
, "2091, 20, Mar, 08:42 GMT, 21, Jun, 02:19 BST, 22, Sep, 18:51 BST, 21, Dec, 15:38 GMT" PRINT #f1
, "2092, 19, Mar, 14:33 GMT, 20, Jun, 08:15 BST, 22, Sep, 00:42 BST, 20, Dec, 21:32 GMT" PRINT #f1
, "2093, 19, Mar, 20:34 GMT, 20, Jun, 14:07 BST, 22, Sep, 06:29 BST, 21, Dec, 03:21 GMT" PRINT #f1
, "2094, 20, Mar, 02:21 GMT, 20, Jun, 19:42 BST, 22, Sep, 12:16 BST, 21, Dec, 09:13 GMT" PRINT #f1
, "2095, 20, Mar, 08:15 GMT, 21, Jun, 01:39 BST, 22, Sep, 18:11 BST, 21, Dec, 15:01 GMT" PRINT #f1
, "2096, 19, Mar, 14:03 GMT, 20, Jun, 07:31 BST, 21, Sep, 23:55 BST, 20, Dec, 20:46 GMT" PRINT #f1
, "2097, 19, Mar, 19:48 GMT, 20, Jun, 13:13 BST, 22, Sep, 05:36 BST, 21, Dec, 02:37 GMT" PRINT #f1
, "2098, 20, Mar, 01:40 GMT, 20, Jun, 19:03 BST, 22, Sep, 11:24 BST, 21, Dec, 08:21 GMT" PRINT #f1
, "2099, 20, Mar, 07:17 GMT, 21, Jun, 00:41 BST, 22, Sep, 17:11 BST, 21, Dec, 14:04 GMT" count = count + 4
HolidayList
(count
- 3).month
= 3: HolidayList
(count
- 3).
name = "Spring Starts" HolidayList
(count
- 2).month
= 6: HolidayList
(count
- 2).
name = "Summer Starts" HolidayList
(count
- 1).month
= 9: HolidayList
(count
- 1).
name = "Autumn Starts" HolidayList
(count
).month
= 12: HolidayList
(count
).
name = "Winter Starts" HolidayList(count - 1).day = d + 1
INPUT #f1
, HolidayList
(count
- 3).day
INPUT #f1
, HolidayList
(count
- 2).day
INPUT #f1
, HolidayList
(count
- 1).day
INPUT #f1
, HolidayList
(count
).day
redo:
IF BackGrounds
(j
) = t
GOTO redo
BackGrounds(i) = t
SUB CenterMonth
(month
, year
) CASE 1: text$
= "January" CASE 2: text$
= "February" CASE 9: text$
= "September" CASE 10: text$
= "October" CASE 11: text$
= "November" CASE 12: text$
= "December" text$
= text$
+ STR$(year
)
TopOffset = 72
LINE (i
* 1280 / 7, 0 + TopOffset
)-STEP(3, 40), _RGBA32(128, 128, 64, 160), BF
TopOffset = TopOffset + 40
LINE (i
* 1280 / 7, 0 + TopOffset
)-STEP(3, 540), _RGBA32(128, 128, 64, 160), BF
FUNCTION ConvertToDay$
(day
) 'Function to return a string for a day CASE 1: ConvertToDay$
= "Sunday" CASE 2: ConvertToDay$
= "Monday" CASE 3: ConvertToDay$
= "Tuesday" CASE 4: ConvertToDay$
= "Wednesday" CASE 5: ConvertToDay$
= "Thursday" CASE 6: ConvertToDay$
= "Friday" CASE 7: ConvertToDay$
= "Saturday"
SUB DrawDays
(month
, year
) TopOffset = 76
bw = 1280 \ 7
t$ = ConvertToDay(i)
TopOffset = TopOffset + 40
nod = NumberOfDays(month, year)
y = 0
x = GetDay(month, i, year)
IF month
= ThisMonth
AND i
= Today
AND ThisYear
= year
THEN LINE ((x
- 1) * 1280 / 7 + 3, y
* 90 + TopOffset
)-STEP(1280 / 7 - 3, 86), _RGBA32(128, 128, 128, 128), BF
'
count = 0
IF month
= HolidayList
(j
).month
AND i
= HolidayList
(j
).day
THEN count = count + 1
_PRINTSTRING ((x
- 1) * 1280 / 7 + 4, (y
+ 1) * 90 + TopOffset
- 5 - count
* 8), LEFT$(HolidayList
(j
).
name, 22)
CASE 1, 3, 5, 7, 8, 10, 12: NumberOfDays
= 31 CASE 2:
IF IsLeapYear
(year
) THEN NumberOfDays
= 29 ELSE NumberOfDays
= 28 CASE 4, 6, 9, 11: NumberOfDays
= 30
FUNCTION IsLeapYear
(yyyy
) 'use 4 digit year IF GetDay
(2, 29, yyyy
) <> GetDay
(3, 1, yyyy
) THEN IsLeapYear
= -1
FUNCTION GetDay
(m
, d
, y
) 'use 4 digit year 'From Zeller's congruence: https://en.wikipedia.org/wiki/Zeller%27s_congruence
mm = m: dd = d: yyyy = y
IF mm
< 3 THEN mm
= mm
+ 12: yyyy
= yyyy
- 1 zerocentury = yyyy \ 100
result
= (dd
+ INT(13 * (mm
+ 1) / 5) + century
+ INT(century
/ 4) + INT(zerocentury
/ 4) + 5 * zerocentury
) MOD 7 GetDay = 7
GetDay = result
'Function changed to return a numeric value instead of a string for this program
' SELECT CASE result
' CASE 7: GetDay$ = "Saturday"
' CASE 1: GetDay$ = "Sunday"
' CASE 2: GetDay$ = "Monday"
' CASE 3: GetDay$ = "Tuesday"
' CASE 4: GetDay$ = "Wednesday"
' CASE 5: GetDay$ = "Thursday"
' CASE 6: GetDay$ = "Friday"
' END SELECT
SHELL _HIDE "cmd /c nslookup myip.opendns.com resolver1.opendns.com>PIP.txt"
IF temp$
<> "" THEN last$
= temp$
'there's a blank line after the data we need. ' Ignore it. What we want is the last line of info generated here.
ip$ = GetPublicIP$(0)
DownloadURL "ip-api.com/line/" + ip$ + "?fields=lat,lon", "LatAndLong.txt"
SUB DownloadURL
(link$
, file$
) out$
= "powershell.exe -c " + CHR$(34) + "Invoke-Webrequest '" + link$
+ "' -OutFile '" + file$
+ "'" + CHR$(34) out$
= "wget " + chr$(34) + link$
+ " -O " + file$
+ chr$(34)
FUNCTION GetHour
(fromTime$
) 'time should be hh:mm:ss WhateverM l
= INSTR(fromTime$
, ":") '1st :
FUNCTION GetMinute
(fromTime$
) 'time should be hh:mm:ss WhateverM l
= INSTR(fromTime$
, ":") '1st : GetMinute
= VAL(MID$(fromTime$
, l
+ 1))
FUNCTION GetSecond
(fromTime$
) 'time should be hh:mm:ss WhateverM l
= INSTR(fromTime$
, ":") '1st : l
= INSTR(l
+ 1, fromTime$
, ":") '2nd : GetSecond
= VAL(MID$(fromTime$
, l
+ 1))
TYPE TIME_ZONE_INFORMATION
StandardName
AS STRING * 64 'WCHAR StandardName[32]; StandardDate
AS SYSTEMTIME
DaylightName
AS STRING * 64 'WCHAR DaylightName[32]; DaylightDate
AS SYSTEMTIME
SUB GetTimeZoneInformation
(t
AS TIME_ZONE_INFORMATION
)
DIM t
AS TIME_ZONE_INFORMATION
GetTimeZoneInformation t
GetTimeOffset = t.Bias
SUB SunStuff
(lat
, lon
, month
, day
, year
) link$
= "https://api.sunrise-sunset.org/json?lat=" + _TRIM$(STR$(lat
)) + "&lng=" DownloadURL link$, "temp.txt"
'strip off unwanted stuff
l
= INSTR(t$
, ":{"): t$
= MID$(t$
, l
+ 2) 'junk left of our initial data t$
= LEFT$(t$
, l
- 1) + MID$(t$
, l
+ 1) 'remove all quotes completely from this data t$
= LEFT$(t$
, l
- 1) + " " + MID$(t$
, l
+ 1) 'change all underscores to spaces in this data t$
= LEFT$(t$
, LEN(t$
) - 12) 'remove the last end of data }
'parse it down to field, data
count = count + 1
h = GetHour(r$): m = GetMinute(r$): s = GetSecond(r$)
h = h - GetTimeOffset / 60
IF h
< 0 THEN h
= 24 + h
'adjust for AM/PM difference, if ever necessary IF h
> 23 THEN h
= h
- 24 'adjust for AM/PM difference, if ever necessary CASE 0: h
= 12: m$
= " AM" CASE IS > 12: h
= h
- 12: m$
= " PM" Sun(count).value = hour$ + ":" + min$ + ":" + sec$ + m$
mooncycle = 29.5305882 'days between moon rotations
sod = 24 * 60 * 60 'number of seconds in a day
dt$ = m$ + "-" + d$ + "-" + y$
guessmoon = TimeStamp(dt$, 23 * 3600 + 59 * 60 + 59) 'what is the moon at 11:59:59 PM
fullmoon = TimeStamp("1-3-2020", 4 * 3600 + 46 * 60) ' full moon on 1-3-2020 at 4:46 AM UTC
dp = (guessmoon - fullmoon) / sod 'days past our full moon
r1
= dp
- INT(dp
/ mooncycle
) * mooncycle
'how far we are in repeating our rotation CASE IS <= mooncycle
/ 4: MoonPhase$
= "1st Quarter" CASE IS <= mooncycle
/ 2: MoonPhase$
= "Full moon" CASE IS <= mooncycle
* 3 / 4: MoonPhase$
= "3rd Quarter"
FUNCTION TimeStamp##
(d$
, t##
) 'date and timer 'Based on Unix Epoch time, which starts at year 1970.
l1
= INSTR(l
+ 1, d$
, "-") IF y
< 1970 THEN 'calculate shit backwards SELECT CASE m
'turn the day backwards for the month CASE 1, 3, 5, 7, 8, 10, 12: d
= 31 - d
'31 days CASE 2: d
= 28 - d
'special 28 or 29. CASE 4, 6, 9, 11: d
= 30 - d
'30 days IF y
MOD 4 = 0 AND m
< 3 THEN 'check for normal leap year, and we're before it... d = d + 1 'assume we had a leap year, subtract another day
IF y
MOD 100 = 0 AND y
MOD 400 <> 0 THEN d
= d
- 1 'not a leap year if year is divisible by 100 and not 400
'then count the months that passed after the current month
CASE 3, 5, 7, 8, 10, 12: d
= d
+ 31 CASE 4, 6, 9, 11: d
= d
+ 30
'we should now have the entered year calculated. Now lets add in for each year from this point to 1970
d = d + 365 * (1969 - y) '365 days per each standard year
FOR i
= 1968 TO y
+ 1 STEP -4 'from 1968 onwards,backwards, skipping the current year (which we handled previously in the FOR loop) d = d + 1 'subtract an extra day every leap year
IF (i
MOD 100) = 0 AND (i
MOD 400) <> 0 THEN d
= d
- 1 'but skipping every year divisible by 100, but not 400 s## = d * 24 * 60 * 60 'Seconds are days * 24 hours * 60 minutes * 60 seconds
TimeStamp## = -(s## + 24 * 60 * 60 - t##)
y = y - 1970
FOR i
= 1 TO m
'for this year, SELECT CASE i
'Add the number of days for each previous month passed CASE 1: d
= d
'January doestn't have any carry over days. CASE 2, 4, 6, 8, 9, 11: d
= d
+ 31 CASE 3 'Feb might be a leap year IF (y
MOD 4) = 2 THEN 'if this year is divisible by 4 (starting in 1972) d = d + 29 'its a leap year
d = d - 1 'the year is divisible by 100, and not divisible by 400
ELSE 'year not divisible by 4, no worries d = d + 28
CASE 5, 7, 10, 12: d
= d
+ 30 d = (d - 1) + 365 * y 'current month days passed + 365 days per each standard year
FOR i
= 2 TO y
- 1 STEP 4 'from 1972 onwards, skipping the current year (which we handled previously in the FOR loopp) d = d + 1 'add an extra day every leap year
IF (i
MOD 100) = 30 AND (i
MOD 400) <> 30 THEN d
= d
- 1 'but skiping every year divisible by 100, but not 400 s## = d * 24 * 60 * 60 'Seconds are days * 24 hours * 60 minutes * 60 seconds
TimeStamp## = (s## + t##)
CASE "Sunday": ConvertDayToNum
= 1 CASE "Monday": ConvertDayToNum
= 2 CASE "Tuseday": ConvertDayToNum
= 3 CASE "Wednesday": ConvertDayToNum
= 4 CASE "Thursday": ConvertDayToNum
= 5 CASE "Friday": ConvertDayToNum
= 6 CASE "Saturday": ConvertDayToNum
= 7