www.sensalgo.com

Holiday ActiveX   Version 1.0      February 2004 

The element calculates the dates of the legal holidays. For every year selected the exact date of the holiday with a textual description of the name of the holiday is available. The US and north German localizations are supported. Further methods for example allow to determinate the weekday of a special date. The main application originally should be the determination of the times shops are closed necessary to forecast the amounts of goods sold on a daily basis.

The associated example shows the basic functionality of the element. It is self explaining. The  application window of the example looks like the following:

Interface Overview

Attributes Short Description
bDynamicYearState The attribute decides, if  the two attributes lState and lYear automatically will change, when methods of the element will be used with parameters that explicitly state another localization or another year as so far set in the attributes lState or lYear.
lState Sets the language and region ('Germany' or 'USA') and implicitly calculates the corresponding dates for future method calls of the element. The language setting only affects the method sIsHoliday(), in respect to return a string in the correct language. All other function are affected by changed dates for different regions.
lYear Sets the year and implicitly calculates the corresponding dates for future method calls of the element. 
Methods Short Description
bIsHoliday Examines for the given up date, whether it is a legal holiday and returns the result as a Boolean value.
dtHoliday Enables you to purposeful inquire the date of all kinds of legal holidays existing in the selected year and for the selected localization.
For both localizations 'USA' and 'Germany' the given up constants for the legal holidays have values from 1 to 11.
dtOrdinaleWeekdayOfMonth The method calculates the date for a special weekday of a special week in a stated month of the selected year. The method helps to calculate further legal holidays that are special for your region.
lWhichWeekday  The method returns the weekday for a given date in a number code.
sIsHoliday The method will examine for the stated date if it is a legal holiday and will return the result as a string filled with its name.

General information concerning the interface as a whole and the usage in .NET you can find under General Information and under Usage in .NET.

Interface Overview

General Information

For more simple parameter give up's to methods the element uses enumerations as much as possible. The following Enum types exist:  

Public Enum enumGermanLegalHolidays
  GE_NewYearsDay = 1
  GE_GoodFriday = 2
  GE_EASTER = 3
  GE_EasterMonday = 4
  GE_LaborDay = 5
  GE_AscensionOfChrist = 6
  GE_Whitsunday = 7
  GE_Whitmonday = 8
  GE_DayOfTheGermanUnification = 9
  GE_ChristmasDay = 10
  GE_BoxingDay = 11
End Enum

Therewith the parameter "Germany" stands only for the north of Germany.

Public Enum enumUSLegalHolidays
  US_NewYearsDay = 1
  US_BirthdayLutherKing = 2
  US_InaugurationDay = 3
  US_WashingtonsBirthday = 4
  US_MemorialDay = 5
  US_IndependenceDay = 6
  US_LaborDay = 7
  US_ColumbusDay = 8
  US_VeteransDay = 9
  US_ThanksgivingDay = 10
  US_ChristmasDay = 11
End Enum

Public Enum enumState
  GERMANY = 1
  USA = 2
End Enum

Public Enum enumWeekday
  MONDAY = 1
  TUESDAY = 2
  WEDNESDAY = 3
  THURSDAY = 4
  FRIDAY = 5
  SATURDAY = 6
  SUNDAY = 7
End Enum

Memory management:

One time calculated return values of previous method calls are not stored in the element. They will newly be calculated each time a method is used.

This is not valid for the calculation of the dates of legal holidays. They are basic for all functions and therefore stored in the element. They only will be calculated newly, if the attributes lState or lYear are changed. This can happen directly by the programmer or implicitly by method calls, if the attribute bDynamicYearState is set to true, which is the default value.

Further more of course the three attributes are stored in the element.  

Interface Overview

Usage in .NET

The method dtHoliday with its declaration 

Public Function dtHoliday(Optional enumIndexGE As enumGermanLegalHolidays = -1, Optional enumIndexUS As enumUSLegalHolidays = -1) As Date

behaves differently. When one of the two optional parameters is left out, what is necessary in every call of this method, the parameter is stated by the system. This will result in an error message.

To avoid this, state both values and the one you want to leave out state with the value -1, for example use

"hd.dtHoliday(-1, a)" instead of "hd.dtHoliday(, a)" respectively

"hd.dtHoliday( a,-1)" instead of "hd.dtHoliday(a)". 

Use the same process with dtOrdinaleWeekdayOfMonth.

bDynamicYearState

bDynamicYearState As Boolean

The attribute determines, whether the two attributes lState and lYear will be automatically adjusted if methods of the element are called with parameters that explicitly state another localization or another year as given as attributes to the element so far.

The default of bDynamicYearState is 'True'. In the case of  'False' the explicit statement of another than the year of the attribute lYear or than the localization of the attribute lState in a method call will result in an error message by the element. This can help to find errors in your application code, in case you need only the dates of a certain year. The following methods are affected by the attribute bDynamicYearState: 

dtHoliday
and
bIsHoliday
dtOrdinaleWeekdayOfMonth
lWhichWeekday
sIsHoliday

The first can change the value of the attribute lState in the case of bDynamicYearState = True, the others can change the value of the attribute lYear in case of bDynamicYearState = True.

Interface Overview

lState

lState As enumState

Gives the information for the localization for the calculation of the legal holidays. The values 1 for 'Germany' and 2 for 'USA' can be selected. Every time the value for lState is changed, all legal holidays are newly calculated.

Interface Overview

lYear

lYear As Long

The year for which the legal holidays are calculated to give a basis for all future calls of element methods. Every time lYear is changed, the legal holidays are newly calculated.

Interface Overview

bIsHoliday

Public Function bIsHoliday(dtDate As Date) As Boolean

The method inquires, whether the date dtDate is a legal holiday, and returns a Boolean value as the result.

When bDynamicYearState equals True (which is the default), the following is effective:
If the year of dtDate is not equal to the attribute lYear, all legal holidays will be newly calculated by an automatic change of the attribute lYear.

In case of errors, the method returns the value 'false'.

Interface Overview

dtHoliday

Public Function dtHoliday(Optional enumIndexGE As enumGermanLegalHolidays = -1, Optional enumIndexUS As enumUSLegalHolidays = -1) As Date

The method supplies purposefully the date of the parameter enumIndexGE respectively enumIndexUS. The legal holiday requested is determined by the year of the attribute lYear and the localization of the attribute lState of the element.

Exactly and only one of both parameters enumIndexGE or enumIndexUS has to be stated. The other  one must be missing.

When bDynamicYearState equals True (which is the default), the following is effective:
If the parameter used does not fit to the localization specified by the attribute lState, lState will be automatically changed. This will result in a new calculation of all legal holidays by the element before this method is executed.

In case of errors, this method will return the first of January of the attribute lYear as a value of the date type.

Interface Overview

dtOrdinaleWeekdayOfMonth

Public Function dtOrdinaleWeekdayOfMonth(lOrdinale As Long, lWeekday As enumWeekday, lMonth As Long, Optional lYear As Long = -1) As Date

The method calculates the date of the weekday given by the parameter lWeekday, which is located in the year of the parameter lYear and in the month of the parameter lMonth. The number of the week this date is located, is given by the parameter lOrdinale. The possible values of lOrdinale count from 1 (first week of the month) to maximal 5 (fifth week of the same month).

For example the third Monday in January 2003 has the date:
dtOrdinaleWeekOfMonth(3,MONDAY,1,2003).

The parameter lYear is optional. If the value is missing, the value of the attribute lYear will be used for calculation. 

When bDynamicYearState equals True (which is the default), the following is effective:
If the parameter lYear is not equal to the the attribute lYear of the element the attribute lYear will be automatically changed by this function to the value of the parameter lYear. This will cause a new calculation of all legal holidays before this method is executed.

If the parameters of the method are stated wrongly an error message will be given out. In this cases the return value of the method will be the date of the first January of the year stated.

Interface Overview

lWhichWeekday

Public Function lWhichWeekday(dtDate As Date) As Long

The method returns the weekday to the date dtDate. The weekday returned is a number between 1 (Monday) to 7 (Sunday).

When bDynamicYearState equals True (which is the default), the following is effective:
If the year of the parameter dtDate is not equal to the attribute lYear of the element, this attribute will be automatically changed. This implies a new calculation of all legal holidays before the method is executed.

Cornerstone of the internal calculation is the Easter date, that always is a Sunday.

In case of errors the method will return -1.

Interface Overview

sIsHoliday

Public Function sIsHoliday(dtDate As Date) As String

The method inquires, whether the date dtDate is a legal holiday. The result will be returned as a string. The string will give back the name of the legal holiday. In case dtDate is no legal holiday, an empty string will be returned.

When bDynamicYearState equals True (which is the default), the following is effective:
If the year of the parameter dtDate is not equal to the attribute lYear of the element, this attribute will be automatically changed. This implies a new calculation of all legal holidays before the method is executed.

Interface Overview