Announcement

Collapse
No announcement yet.

[Includes][Script][ASP]Check if date is a holiday/Calendar V3.5

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • [Includes][Script][ASP]Check if date is a holiday/Calendar V3.5

    The attached ZIP file contains a function to check if a date is a holiday. The function reads the holidays/events from an INI file and returns the names of the holidays/events along with other parameters. Examples of how to use the function are included. The examples include ASP based calendars and scripts that will announce events and remind you prior to those events occurring.

    The functions, ASP pages and scripts are designed to be non-locale specific so can be used in other countries where the names of the months and weekdays are different.

    The discussion for the script is here: http://board.homeseer.com/showthread.php?t=95611&page=1.

    The ZIP file contains the following files:

    1. isholiday.asp - This file contains the primary function (WhichHolidays). This function can be used from your own ASP pages if you add the following line at the top of those ASP pages:

    <!--#include virtual="/includes/isholiday.asp"-->
    Put this file in your HomeSeer /html/includes folder.

    2. isholiday.vbs - This file also contains the primary function (WhichHolidays) This function can be used from your own scripts if you add the following line at the top of those scripts:

    #Include includes/isholiday.vbs

    Put this file in your HomeSeer /script/includes folder.

    3. isholiday.ini - This is the config file that contains the holidays. Put this file in your HomeSeer config folder. It contains Canadian, U.S. and U.K. holidays.

    The file uses a [Holidays] section and the entries in it need to use the following syntax:

    Display Name = Event Date

    Event Date can take on the following formats
    A. If the event is on a fixed date use the format Month Date
    (see New Year's Day as an example of this type)
    B. If the event is on a fixed day of the week in a month use the format Month,Weekday,number where number is either 1,2,3,4 orlast. (see Labor Day as an example (it's the 1st Monday in September and the syntax for it = Labor Day=September,Monday,1.
    C. Use the word(s) Easter, Easter Monday, Easter Saturday and Good Friday for those specific dates if you observe them.
    D. If the event is on a specific date in a year, use the format Month Date, Year
    This can be used for vacations or non-recurring holidays/events.
    E. If the event occurs once a week, then use the weekday like Tuesday.
    F. If the event occurs once a month on the same day, then use the day like 4. This would be for every 4th day of every month.
    G. If the event occurs once a month on a fixed weekday, then use the format Weekday,number where number is either 1,2,3,4 orlast. As an example, Tuesday,3 for every third Tuesday of every month.
    H. Use the words Full Moon to have the function return if the full moon falls on the given date.

    In addition to the name of the holiday/event and the date value from the INI file, the scripts will return other parameters as well. These parameters are:

    Announce True/False. Set this to False if you don't want the event announced.
    Announcement Text. Set this to the text that you want spoken or displayed as the announcement. You can use the keyword %HOWMANYYEARS% in announcement to insert the number of the anniversary, birthday, etc. This requires the Year parameter to be set. As an example, you could use "Uncle Bob is %HOWMANYYEARS% years old" which would return Uncle Bob is 41 years old in 2004 if Year was set to 1963.
    Remind True/False. Set this to False if you don't want to be reminded about the event.
    RemindPrior Integer. Set this to the number of days prior to the event that you want the reminders to start.
    ChangeBehavior True/False. Set this to False if you don't want other scripts to change their behavior based on this event/holiday.
    ShowOn Calendar True/False. Set this to False if you don't want specific events to be displayed on the calendars included with the package..
    Image path to image file. Set this to a path of an image. You can use this to display different images depending on which holiday it is (Allows you to do like what Google does with their logo on special occasions). NOTE: This parameter is not used in any of the scripts provided.
    Email email address. Set this to the email address that you want a script to use to send emails to. NOTE: This parameter is not used in any of the scripts provided.
    Private True/False. Set this to True if you don't want guests to see the event.
    Year Year. What year the event first occurred.
    YearValue Integer. Offset for Year. (Use this if the Year parameter is not the first year, but a subsequent year). As an example, if Uncle Bob's 40th birthday was in 2003, you could enter 2003 in Year and 40 in YearValue or you could enter 1963 in Year and leave YearValue blank.
    Year Prefix Text. Text to prepend to an anniversary or birthday.
    Year Suffix Text. Text to append to an anniversary or birthday.
    Person Text. Name of person the event is for. Leave blank if the event applies to more than one person. cal.asp can display events for different people with different format fonts (such as color), if you create an entry in the style sheet with the name of each person. See cal.css for examples of this.
    Time Time. Time the event occurs. Leave blank for all-day events

    To set these parameters, create a section with the exact same name as the event or holiday (see below) or use cal.asp and click on the days you want to create events for, or to modify existing events. A popup will open allowing you to edit, create and delete events.

    [Christmas Day]
    Announcement=Merry Christmas
    Image=/images/christmas.gif
    Remind=False
    RemindPrior=7
    Announce=True
    ChangeBehaviour=True
    ShowOnCalendar=True
    Email=santa@northpole.com
    Private=False

    [Uncle Bob's Birthday]
    Year=1963
    YearPrefix=
    YearSuffix=years old
    Announcement=Uncle Bob is %HOWMANYYEARS% years old

    [Some Meeting]
    Person=Bob
    Time=10 AM

    There's also a section with default parameters:

    [Settings]
    DefaultAnnounce=True
    DefaultAnnouncementPrefix=
    DefaultAnnouncementSuffix=
    DefaultRemind=True
    DefaultChangeBehavior=True
    DefaultShowOnCalendar=True
    DefaultImage=/images/default.gif
    DefaultRemindPrior=7
    DefaultEmail=someone@domain.com
    DefaultPrivate=False
    YearPrefix=(
    YearSuffix=)

    and a section with default parameters for Birthdays:

    [Birthday]
    AnnouncementPrefix=
    AnnouncementSuffix=
    Private=True
    ChangeBehavior=False
    ShowOnCalendar=True

    The Default Parameters in the [Settings] and [Birthday] sections must be manually edited in the INI file.

    The script will use the default Parameters in the Birthday section if the event name includes Birthday, B-day, B'day or Bday.

    You don't have to have these sections for each holiday or event. You only need them for the holidays/events that you want to change the default paramters for. See the INI file in the ZIP file for more examples.

    4. todayholiday.asp - is an example of how the function can be called from within an ASP page. Place this in the HomeSeer /html/cal folder. The file also demonstrates how cal2.asp can be embedded in other ASP pages using the inline element.

    5. wakeup.txt - is an example of how the function can be used from within a script. This particular script is the one I use to turn on my stereo every weekday morning. If it's a holiday, it won't turn it on.

    6. wakeup2.txt - is a script written by JohnWPB that will announce upcoming events and holidays.

    7. cal.asp - is another example of how the function can be used from within an ASP page. This will display an on-screen calendar and show the holidays/events. You can edit events by (double) clicking on a date in the calendar. Place this in the HomeSeer /html/cal folder.

    The formatting of the calendar is controlled by a Style Sheet (cal.css). You can also use machine specific (based on IP Address) formatting by creating a style sheet file with the name cal-xxx-xxx-xxx-xxx.css Where xxx represents the non-zero padded IP address (example cal-192-168-1-100.css). If there's no machine specific style sheet, the default style sheet (cal.css) will get used.

    8. cal2.asp - This will display a small on-screen calendar. The holidays/events are displayed by clicking on a date. You can edit events by double-clicking on a date. Note, this uses DHTML and has only been tested on IE 5.5 and IE 6. It may not work on other browsers. Place this in the HomeSeer /html/cal folder.

    The formatting of this calendar is also controlled by a Style Sheet (cal2.css). Again, you can also use machine specific (based on IP Address) formatting by creating a style sheet file with the name cal2-xxx-xxx-xxx-xxx.css.

    9. cal.ini - This config file contains some of the display options for cal.asp, cal2.asp and caledit.asp that aren't contained in the style sheets. You can use this to change the titles of the pages, and change the text displayed on the buttons, links, etc. Place this in your HomeSeer /config folder.

    10. cal.css - This is the style sheet for cal.asp and controls the formatting of the calendar. Place this in the HomeSeer /html/cal folder.

    11. cal2.css - This is the style sheet for cal2.asp and controls the formatting of the calendar. Place this in the HomeSeer /html/cal folder.

    12. caledit.asp - allows you to add, delete and edit entries in the INI file by clicking on dates on the calendar. Place this in the HomeSeer /html/cal folder.
    Attached Files
    Last edited by sparkman; January 4th, 2005, 10:06 PM.
    HS 3.0.0.548: 1965 Devices 1146 Events
    Z-Wave 3.0.1.262: 122 Nodes on one Z-Net

  • #2
    HS3 Version

    The attached ZIP file contains files to check if a date is a holiday or has another event on that day and has been updated for HS3 and all scripts have been converted to vb.net.

    The calendar is stored in an INI file, but can be edited and maintained using a web page:

    Click image for larger version

Name:	cal.jpg
Views:	1
Size:	56.5 KB
ID:	1183722

    The function reads the holidays/events from an INI file and returns the names of the holidays/events along with other parameters. Examples of how to use the function are included. The examples include ASP based calendars and scripts that will announce events and remind you prior to those events occurring.

    The functions, ASP pages and scripts are designed to be non-locale specific so can be used in other countries where the names of the months and weekdays are different.

    The discussion for the script is here: http://board.homeseer.com/showthread.php?t=95611&page=1.

    The ZIP file contains the following files:

    1. isholiday.asp - This file contains the primary function (WhichHolidays). This function can be used from your own ASP pages if you add the following line at the top of those ASP pages:

    <!--#include virtual="/includes/isholiday.asp"-->
    Put this file in your HomeSeer /html/includes folder.

    2. isholiday.vb - This file also contains the primary function (WhichHolidays) This function can be used from your own vb.net scripts if you add the following line at the top of those scripts:

    #Include includes/isholiday.vb

    Put this file in your HomeSeer /scripts/includes folder.

    3. isholiday.ini - This is the config file that contains the holidays. Put this file in your HomeSeer /config folder. It contains Canadian and U.S. holidays.

    The file uses a [Holidays] section and the entries in it need to use the following syntax:

    Display Name = Event Date

    Event Date can take on the following formats
    A. If the event is on a fixed date use the format Month Date
    (see New Year's Day as an example of this type)
    B. If the event is on a fixed day of the week in a month use the format Month,Weekday,number where number is either 1,2,3,4 orlast. (see Labor Day as an example (it's the 1st Monday in September and the syntax for it = Labor Day=September,Monday,1.
    C. Use the word(s) Easter, Easter Monday, Easter Saturday and Good Friday for those specific dates if you observe them.
    D. If the event is on a specific date in a year, use the format Month Date, Year
    This can be used for vacations or non-recurring holidays/events.
    E. If the event occurs once a week, then use the weekday like Tuesday.
    F. If the event occurs once a month on the same day, then use the day like 4. This would be for every 4th day of every month.
    G. If the event occurs once a month on a fixed weekday, then use the format Weekday,number where number is either 1,2,3,4 orlast. As an example, Tuesday,3 for every third Tuesday of every month.
    H. Use the words Full Moon to have the function return if the full moon falls on the given date.

    In addition to the name of the holiday/event and the date value from the INI file, the scripts will return other parameters as well. These parameters are:

    Announce True/False. Set this to False if you don't want the event announced.
    Announcement Text. Set this to the text that you want spoken or displayed as the announcement. You can use the keyword %HOWMANYYEARS% in announcement to insert the number of the anniversary, birthday, etc. This requires the Year parameter to be set. As an example, you could use "Uncle Bob is %HOWMANYYEARS% years old" which would return Uncle Bob is 41 years old in 2004 if Year was set to 1963.
    Remind True/False. Set this to False if you don't want to be reminded about the event.
    RemindPrior Integer. Set this to the number of days prior to the event that you want the reminders to start.
    ChangeBehavior True/False. Set this to False if you don't want other scripts to change their behavior based on this event/holiday.
    ShowOn Calendar True/False. Set this to False if you don't want specific events to be displayed on the calendars included with the package..
    Image path to image file. Set this to a path of an image. You can use this to display different images depending on which holiday it is (Allows you to do like what Google does with their logo on special occasions). NOTE: This parameter is not used in any of the scripts provided.
    Email email address. Set this to the email address that you want a script to use to send emails to. NOTE: This parameter is not used in any of the scripts provided.
    Private True/False. Set this to True if you don't want guests to see the event.
    Year Year. What year the event first occurred.
    YearValue Integer. Offset for Year. (Use this if the Year parameter is not the first year, but a subsequent year). As an example, if Uncle Bob's 40th birthday was in 2003, you could enter 2003 in Year and 40 in YearValue or you could enter 1963 in Year and leave YearValue blank.
    Year Prefix Text. Text to prepend to an anniversary or birthday.
    Year Suffix Text. Text to append to an anniversary or birthday.
    Person Text. Name of person the event is for. Leave blank if the event applies to more than one person. cal.asp can display events for different people with different format fonts (such as color), if you create an entry in the style sheet with the name of each person. See cal.css for examples of this.
    Time Time. Time the event occurs. Leave blank for all-day events

    To set these parameters, create a section with the exact same name as the event or holiday (see below) or use cal.asp and click on the days you want to create events for, or to modify existing events. A popup will open allowing you to edit, create and delete events.

    [Christmas Day]
    Announcement=Merry Christmas
    Image=/images/christmas.gif
    Remind=False
    RemindPrior=7
    Announce=True
    ChangeBehaviour=True
    ShowOnCalendar=True
    Email=santa@northpole.com
    Private=False

    [Uncle Bob's Birthday]
    Year=1963
    YearPrefix=
    YearSuffix=years old
    Announcement=Uncle Bob is %HOWMANYYEARS% years old

    [Some Meeting]
    Person=Bob
    Time=10 AM

    There's also a section with default parameters:

    [Settings]
    DefaultAnnounce=True
    DefaultAnnouncementPrefix=
    DefaultAnnouncementSuffix=
    DefaultRemind=True
    DefaultChangeBehavior=True
    DefaultShowOnCalendar=True
    DefaultImage=/images/default.gif
    DefaultRemindPrior=7
    DefaultEmail=someone@domain.com
    DefaultPrivate=False
    YearPrefix=(
    YearSuffix=)

    and a section with default parameters for Birthdays:

    [Birthday]
    AnnouncementPrefix=
    AnnouncementSuffix=
    Private=True
    ChangeBehavior=False
    ShowOnCalendar=True

    The Default Parameters in the [Settings] and [Birthday] sections must be manually edited in the INI file.

    The script will use the default Parameters in the Birthday section if the event name includes Birthday, B-day, B'day or Bday.

    You don't have to have these sections for each holiday or event. You only need them for the holidays/events that you want to change the default parameters for. See the INI file in the ZIP file for more examples.

    4. todayholiday.asp - is an example of how the function can be called from within an ASP page. Place this in the HomeSeer /html folder. The file also demonstrates how cal2.asp can be embedded in other ASP pages using the inline element.

    5. AnnounceEvents.vb - is a script written that will announce (speak) upcoming events and holidays. Put this in the HomeSeer /scripts folder.

    6. cal.asp - is another example of how the function can be used from within an ASP page. This will display an on-screen calendar and show the holidays/events. You can edit events by (double) clicking on a date in the calendar. Place this in the HomeSeer /html folder.

    The formatting of the calendar is controlled by a Style Sheet (cal.css). You can also use machine specific (based on IP Address) formatting by creating a style sheet file with the name cal-xxx-xxx-xxx-xxx.css Where xxx represents the non-zero padded IP address (example cal-192-168-1-100.css). If there's no machine specific style sheet, the default style sheet (cal.css) will get used.

    7. cal2.asp - This will display a small on-screen calendar. The holidays/events are displayed by clicking on a date. You can edit events by double-clicking on a date. Note, this uses DHTML and has only been tested on IE 5.5 and IE 6. It may not work on other browsers. Place this in the HomeSeer /html folder.

    The formatting of this calendar is also controlled by a Style Sheet (cal2.css). Again, you can also use machine specific (based on IP Address) formatting by creating a style sheet file with the name cal2-xxx-xxx-xxx-xxx.css.

    8. cal.ini - This config file contains some of the display options for cal.asp, cal2.asp and caledit.asp that aren't contained in the style sheets. You can use this to change the titles of the pages, and change the text displayed on the buttons, links, etc. Place this in your HomeSeer /config folder.

    9. cal.css - This is the style sheet for cal.asp and controls the formatting of the calendar. Place this in the HomeSeer /html folder.

    11. cal2.css - This is the style sheet for cal2.asp and controls the formatting of the calendar. Place this in the HomeSeer /html folder.

    12. caledit.asp - allows you to add, delete and edit entries in the INI file by clicking on dates on the calendar. Place this in the HomeSeer /html folder.

    13. isholidaytoday.vb, isholidaytomorrow.vb, schooldaytoday.vb, schoolddaytomorrow.vb - These are example scripts that will change virtual devices to show what holidays are upcoming and the school ones will check the calendar for a "No School" event and if so change virtual devices to show whether today and tomorrow are school days.
    Last edited by sparkman; March 6th, 2016, 06:27 PM.
    HS 3.0.0.548: 1965 Devices 1146 Events
    Z-Wave 3.0.1.262: 122 Nodes on one Z-Net

    Comment

    Working...
    X