Send an email in non holiday day

I have a function in python and i need to create like this function in basic code:

import datetime

def isHoliday(date):
    holidays = [
        datetime.date(2023, 1, 1),   # New Year's Day
        datetime.date(2023, 4, 17),  # Easter Monday
        datetime.date(2023, 5, 1),   # Labor Day
        datetime.date(2023, 5, 8),   # Victory in Europe Day
        datetime.date(2023, 5, 25),  # Ascension Day
        datetime.date(2023, 6, 5),   # Whit Monday
        datetime.date(2023, 7, 14),  # Bastille Day
        datetime.date(2023, 8, 15),  # Assumption of Mary
        datetime.date(2023, 11, 1),  # All Saints' Day
        datetime.date(2023, 11, 11), # Armistice Day
        datetime.date(2023, 12, 25), # Christmas Day
    ]
    return date in holidays

the function return if the today’s date in holiday or not and then i will send an email if it’s not

Hi ACD,

In BASIC, you can get the Ewon’s current time and date with the variable TIME$, which returns a string. After assigning this to another string variable, you can extract substrings with the following syntax.

CurrentTime$ = TIME$
Today$ = CurrentTime$(1 to 10)
Year$ = CurrentTime$(7 to 10)

Which would yield:

  • CurrentTime$ = “21/02/2023 10:55:00”
  • Today$ = “21/02/2023”
  • Year$ = “2023”

You can compare the dates you extract with strings you set to represent each holiday in order to see if today is a holiday.

Hi Hugh,
I m using this method, but I want to know if there’s a function inside BASIC to compare the current_date to a list of holiday dates. to give you more information I want to create a table in which I will put all my holiday dates and the inside the is_holiday function I will compare the current_date to the list of holidays !?

Hi ACD,

No, there’s no function that checks if something is a member of a list. However, you can create a list of strings by declaring DIM Holidays$(11,10). This creates an array with 11 members, each with 10 characters. You can then fill your array with statements like Holidays$(1) = "01/01/2023" and compare them to the current date string with the code I shared in my last comment.

CurrentTime$ = TIME$
Today$ = CurrentTime$(1 to 10)
PRINT Today$ = Holidays$(1) //returns 1 (true) if Today$ matches Holidays$(1)

Probably the easiest way to approach this would be to create a function that loops through the array, checking for a match and returning true if it finds one.

1 Like