Jump to content
Tom Wellige

Public Holidays (in Austria, incl. Federal States)

Recommended Posts

Based on the initial version of the function IsPublicHolidayDE written by JoergG, which checks for public holidays in Germany, kroni99 has created a new version to check for public holidays in Austria.

 

 

The following VBScript function calculates public holidays in Austria. The function even takes the different federal states into consideration.

 

'-------------------------------------------------------------------
' 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

 

 

*** USAGE ***

 

To use this function in your Call Routing scripts just do the following:

 

  • Copy & Paste the above code into the Properties page of your script's Start block.
     
  • Now it can be used practically everywhere within the GSE, the most easiest place with be the Evaluate block. This would have the advantage that the return value from the function (is public holiday or not) is directly mapped on the two exits (True and False) of the block.

    To call the function just place the function call into the text field of the Properties page of the Evaluate block.

    Examples:

    Check in Wien for current date:

      IsPublicHolidayAT(vb_FS_WI, "") 
      IsPublicHolidayAT(vb_FS_WI, Now) 

    Check in Kärnten and Tirol for a given date:

      IsPublicHolidayAT(vb_FS_KA or vb_FS_TI, "01.05.2015") 

 

 

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).

 

 

*** ANLEITUNG ***

 

Um diese Funktion zur in einem eigenen Call Routing Skript zu verwenden, einfach die folgenden Schritte befolgen:

 

  • Den obigen Skript Code in die Eigenschaften Seite des Start Blocks kopieren.
     
  • Nun kann die Funktion beinahe überall im GSE direkt aufgerufen werde. Der sinnvollste Ort dafür ist sicherlich der Variable auswerten Block. Dies hat den Vorteil, dass der Rückgabewert der Funktion (gegebenes Datum ist ein Feiertag oder nicht) direkt auf einen der beiden Ausgänge (Wahr oder Falsch) geleitet wird.

    Um die Funktion aufzurufen, einfach den Funkitonsaufruf in das Textfeld auf der Eigenschaften Seite des Variable auswerten Blocks eintragen.

    Beispiele:

    Überprüfe in Wien für aktuelles Datum:

      IsPublicHolidayAT(vb_FS_WI, "")
      IsPublicHolidayAT(vb_FS_WI, Now)  


    Überprüfe in Kärnten und Tirol für ein bestimmtes Datum:

      IsPublicHolidayAT(vb_FS_KA or vb_FS_TI, "01.05.2015") 

 

 

Der erste Parameter ist das Bundesland (bzw. auch eine per OR verknüpfte Liste mehrer Bundesländer). Eine komplette Liste der verfügbaren Bundesländer und ihrer zu verwendenen Kürzel befindet sich am Anfang des Codes.

 

Der zweite Parameter ist das Datum, welches überprüft werden soll. Dies kann entweder ein VBSkript Variant Typ sein (wie ihn z.B. die Funktion Now zurück liefert oder aus einem Datenbank Feld vom Typ datetime geladen wurde) oder eine Zeichenkette (String) welche das Datum representiert. Zu beachten ist in diesem Fall, dass das Datum gemäß der regionalen Einstellungen der Server Maschine formatiert werden muss.

 

 

Thank you,

Dominik and Jörg!

 

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   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.

Loading...

×
×
  • 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.