/// <summary>
/// 根据指定日期,计算出给定时间间隔的下一个工作日的日期
/// </summary>
/// <param name="dt">给定的日期</param>
/// <param name="n">时间间隔</param>
/// <returns>下一个工作日的日期</returns>
private static Int32 ResultDateTime(DateTime dt)
{
DateTime temp = dt;
int count = -1;
if (temp != null)
{
string strTempDate = temp.ToString().Split(' ')[0];
string[] st = strTempDate.Split('/');
string y = st[0];
string m = "";
string d = "";
if (st[1].Length == 1)
{
m = "0" + st[1];
}
else
{
m = st[1];
}
if (st[2].Length == 1)
{
d = "0" + st[2];
}
else
{
d = st[2];
}
string s = y + m + d;
string strUrl = "http://api.goseek.cn/Tools/holiday?date=" + s;
Uri uri = new Uri(strUrl);
WebRequest req = WebRequest.Create(uri);
WebResponse resp = req.GetResponse();
StreamReader reader = new StreamReader(resp.GetResponseStream(), Encoding.ASCII);
string strTemp = reader.ReadToEnd();
JavaScriptSerializer serializer = new JavaScriptSerializer();
Dictionary<string, object> json = serializer.DeserializeObject(strTemp) as Dictionary<string, object>;
object value;
json.TryGetValue("data", out value);
count = Int32.Parse(value.ToString());
}
return count;
}
C# 根据指定日期,计算出给定时间间隔的下一个工作日的日期
最新推荐文章于 2022-04-28 10:23:19 发布