Jump to content
Gold Sponsor: Data-Way IT-Consulting, Austria

  • IsPublicHolidayAT

    IsPublicHolidayAT

    VBScript

     

    This function checks a given date for a public holiday in Austria. It takes the different federal states into consideration.

    Please see the Introduction chapter for some usage instructions.

     

    '-------------------------------------------------------------------
    ' Feiertagsüberprüfung Österreich
    '
    ' Author: Dominik Kronsteiner (PCH IT Solution GmbH - www.pch.at)
    '
    ' Version: v1.1 - 2019-09-05
    '-------------------------------------------------------------------
    
    ' Österreich
    const vb_FS_NO = 1	' Niederösterreich
    const vb_FS_OO = 2	' Oberösterreich
    const vb_FS_WI = 4	' Wien
    const vb_FS_SM = 8	' Steiermark
    const vb_FS_KA = 16	' Kärnten
    const vb_FS_BU = 32	' Burgenland
    const vb_FS_SA = 64	' Salzburg
    const vb_FS_TI = 128	' Tirol
    const vb_FS_VO = 256	' Vorarlberg
    
    
    '-------------------------------------------------------------------
    ' Name:     IsPublicHolidayAT
    '           =================
    '
    ' Returns true if the given date is a public holiday in the given Austrian
    ' federal state. Multiple federal states can be combined with "OR"
    '
    ' Parameter:
    '   nFederalState     single or combination of federal states
    '   vCheckDate        vbscript date to check (e.g. as returned by now) or 
    '                     "" (for current date)
    '
    ' Returns:
    '   Boolean           True = is public holiday
    '
    '--------------------------------------------------------------------
    Function IsPublicHolidayAT ( nFederalState, vCheckDate )
    
    	On Error Resume Next
    	PBXScript.OutputTrace "Holiday - -------> IsPublicHolidayAT"    
    	PBXScript.OutputTrace "Holiday - nFederalState = " & nFederalState    
    	PBXScript.OutputTrace "Holiday - vCheckDate = " & vCheckDate    
    
    	Dim bReturn    
    	bReturn = False    
    
    	Dim sReturn
    	sReturn = "No Holiday Found"
    
    	Dim a, b, c, d, e, f    
    	Dim nTempYear, vTempDate  
    	Dim Neujahr, dreiKoenige, Josef, Karfreitag, Ostersonntag, Ostermontag    
    	Dim Staatsfeiertag, Florian, ChrHimmelfahrt, Pfingstmontag, Fronleichnam    
    	Dim MarieaeHimmelfahrt, Rupert, TagderVolksabstimmung, Nationalfeiertag
    	Dim Allerheiligen, Martin, Leopold, MariaeEmpfaengnis, HeiligAbend, Christtag, Stefanitag, Silvester
    
    	if not IsDate(vCheckDate) then vCheckDate = Now
    
    	vTempDate = DateSerial(Year(vCheckDate), Month(vCheckDate), Day(vCheckDate))    
    	nTempYear = Year(vTempDate)    
    	PBXScript.OutputTrace "Holiday - Using nTempYear = " & nTempYear    
    	PBXScript.OutputTrace "Holiday - Using vTempDate = " & vTempDate
    
    	' Gauß Formel
    	a = nTempYear Mod 19    
    	b = nTempYear \ 100    
    	c = (8 * b + 13) \ 25 - 2    
    	d = b - (nTempYear \ 400) - 2    
    	e = (19 * (nTempYear Mod 19) + ((15 - c + d) Mod 30)) Mod 30    
    
    	if e = 28 then
    		if a > 10 then 
    			e = 27
    		end if
    	elseif e = 29 then
    		e = 28    
    	end if    
      
    	f = (d + 6 * e + 2 * (nTempYear Mod 4) + 4 * (nTempYear Mod 7) + 6) Mod 7    
      
    	' Feiertage konfigurieren    
    	Neujahr			= DateSerial(nTempYear, 1, 1)
    	dreiKoenige		= DateSerial(nTempYear, 1, 6)
    	Josef			= DateSerial(nTempYear, 3, 19)
    	Karfreitag		= DateSerial(nTempYear, 3, e + f + 22 - 2)
    	Ostersonntag		= DateSerial(nTempYear, 3, e + f + 22)
    	Ostermontag		= DateSerial(nTempYear, 3, e + f + 22 + 1)    
    	Staatsfeiertag		= DateSerial(nTempYear, 5, 1)
    	Florian			= DateSerial(nTempYear, 5, 4)
    	ChrHimmelfahrt		= DateSerial(nTempYear, 3, e + f + 22 + 39)    
    	Pfingstmontag		= DateSerial(nTempYear, 3, e + f + 22 + 50)    
    	Fronleichnam		= DateSerial(nTempYear, 3, e + f + 22 + 60)
    	MarieaeHimmelfahrt	= DateSerial(nTempYear, 8, 15)
    	Rupert			= DateSerial(nTempYear, 9, 24)
    	TagderVolksabstimmung	= DateSerial(nTempYear, 10, 10)     
    	Nationalfeiertag	= DateSerial(nTempYear, 10, 26)     
    	Allerheiligen		= DateSerial(nTempYear, 11, 1)
    	Martin			= DateSerial(nTempYear, 11, 11)
    	Leopold			= DateSerial(nTempYear, 11, 15)
    	MariaeEmpfaengnis	= DateSerial(nTempYear, 12, 8)
    	HeiligAbend		= DateSerial(nTempYear, 12, 24)
    	Christtag		= DateSerial(nTempYear, 12, 25)
    	Stefanitag		= DateSerial(nTempYear, 12, 26)
    	Silvester		= DateSerial(nTempYear, 12, 31)
      
      
    	' Feiertag?   
    	select case vTempDate        
    		case Neujahr            
    			bReturn = True
    			sReturn = "Neujahr"
    		case dreiKoenige
    			bReturn = True
    			sReturn = "dreiKoenige"
    		case Karfreitag
    			bReturn = True
    			sReturn = "Karfreitag"
    		case Ostermontag
    			bReturn = True
    			sReturn = "Ostermontag"
    		case Staatsfeiertag
    			bReturn = True
    			sReturn = "Staatsfeiertag"
    		case ChrHimmelfahrt
    			bReturn = True
    			sReturn = "ChrHimmelfahrt"
    		case Pfingstmontag
    			bReturn = True
    			sReturn = "Pfingstmontag"
    		case Fronleichnam
    			bReturn = True
    			sReturn = "Fronleichnam"
    		case MarieaeHimmelfahrt
    			bReturn = True
    			sReturn = "MarieaeHimmelfahrt"
    		case Nationalfeiertag
    			bReturn = True
    			sReturn = "Nationalfeiertag"
    		case Allerheiligen
    			bReturn = True
    			sReturn = "Allerheiligen"
    		case MariaeEmpfaengnis
    			bReturn = True
    			sReturn = "MariaeEmpfaengnis"
    		case HeiligAbend
    			bReturn = True
    			sReturn = "HeiligAbend"
    		case Christtag
    			bReturn = True
    			sReturn = "Christtag"
    		case Stefanitag
    			bReturn = True
    			sReturn = "Stefanitag"
    		case Silvester
    			bReturn = True
    			sReturn = "Silvester"
    		case Josef
    			if (nFederalState and (vb_FS_KA or vb_FS_SM or vb_FS_TI or vb_FS_VO or vb_FS_WI)) then bReturn = True
    			sReturn = "Josef"
    		case Florian
    			if (nFederalState and (vb_FS_OO)) then bReturn = True
    			sReturn = "Florian"
    		case Rupert
    			if (nFederalState and (vb_FS_SA)) then bReturn = True
    			sReturn = "Rupert"
    		case TagderVolksabstimmung
    			if (nFederalState and (vb_FS_KA)) then bReturn = True
    			sReturn = "TagderVolksabstimmung"
    		case Martin
    			if (nFederalState and (vb_FS_BU)) then bReturn = True
    			sReturn = "Martin"
    		case Leopold
    			if (nFederalState and (vb_FS_NO or vb_FS_WI)) then bReturn = True
    			sReturn = "Leopold"
    	end select    
    
    	IsPublicHolidayAT = bReturn    
    
    	PBXScript.OutputTrace "Holiday - bReturn = " & bReturn  
    	PBXScript.OutputTrace "Holiday - " & sReturn
    	PBXScript.OutputTrace "Holiday - <------- IsPublicHolidayAT"
      
    End Function

     

     

    The first parameter of the function is either one or a list federal states (linked by OR). See the above code for the possible values for each federal state.

     

    The second parameter is the date to check. This can either be a VBScript variant type (like e.g. Now returns or have been loaded from a database field of type datetime) or a string representing the date to be checked. Please note that in this case the string must be a valid date according the the regional settings configuration of your server machine (in regard to is format).
     

    Examples
     

    • Check in Wien for current date:

        IsPublicHolidayAT(vb_FS_WI, "") 
        IsPublicHolidayAT(vb_FS_WI, Now) 
       
    • Check in Kärnten and Tirol for a fixed given date:

        IsPublicHolidayAT(vb_FS_KA or vb_FS_TI, "01.05.2015") 

     

     

    This function is based on the initial version IsPublicHolidayDE written by JoergG. kroni99 has created a new version to check for public holidays in Austria.

     

    This function was initially posted into this forum topic.

     

     


    Tom Wellige
     Share


     Share




    User Feedback

    Recommended Comments

    There are no comments to display.



    Guest
    Add a comment...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and have taken note of our Privacy Policy.
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.