This script demonstrates how to retrieve a Holiday Set and get a list of the holiday dates that it defines
Created
November 29, 2021 15:01
-
-
Save arcanadev/ccd090e5e56c11abfa19591387ca9230 to your computer and use it in GitHub Desktop.
Get dates for a Holiday Set #adTempus #api #version4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Main() | |
{ | |
//if the adTempus server is on a different computer, replace "." with the name | |
using (var session = Scheduler.Connect(".", LoginAuthenticationType.Windows, "", "")) | |
{ | |
using (var context = session.NewDataContext()) | |
{ | |
//retrieve the Holiday Set | |
var holidays=context.GetHolidaySet("Standard U.S. Holidays"); | |
if(holidays==null) | |
return; | |
var startDate=new DateTime(2021,1,1); | |
var endDate=startDate.AddYears(1); | |
var matchingDates=holidays.GetMatchingDates(startDate, endDate); | |
foreach(var item in matchingDates) | |
{ | |
Console.WriteLine($"{item.MatchingDate} ({item.RuleName})"); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment