Skip to content

Instantly share code, notes, and snippets.

@arcanadev
Created November 29, 2021 15:01
Show Gist options
  • Save arcanadev/ccd090e5e56c11abfa19591387ca9230 to your computer and use it in GitHub Desktop.
Save arcanadev/ccd090e5e56c11abfa19591387ca9230 to your computer and use it in GitHub Desktop.
Get dates for a Holiday Set #adTempus #api #version4

This script demonstrates how to retrieve a Holiday Set and get a list of the holiday dates that it defines

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