if your broker/platform provides a decent api it will usually have calendar functions.
alternatively, since the nyse posts it's schedule way in advance you can roll your own:
public static bool isEarlyClose(int today)
{
try
{
return GetCloseTime().Contains(today);
}
catch (Exception) { return false; }
}
public static int GetEarlyClose(int today)
{
try
{
return (int)GetCloseTime()[today];
}
catch (Exception) { return 0; }
}
public static Hashtable GetCloseTime()
{
StreamReader f = new StreamReader("EarlyClose.csv");
string[] r = new string[2];
string line = "";
Hashtable h = new Hashtable();
while ((line = f.ReadLine())!=null)
{
r = line.Split(',');
h.Add(Convert.ToInt32(r[0]),Convert.ToInt32(r[1]));
}
f.Close();
return h;
}
http://tradelink.googlecode.com/svn/trunk/TradeLib/Util.cs