using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CP.Common
{
///
/// 彩种期数计算相关
///
public class TermUtil
{
///
/// 获取下一期号
///
///
///
///
public static long GetNextQi(long qi, string lottery)
{
long year = qi / 1000;
long endQi = year * 1000 + 153;
if (lottery == "3d" || lottery == "p3" || lottery == "hc1")
{
endQi = endQi + 205;
if (2014 == year)//2014年少一期
{ endQi = endQi - 1; }
}
if (0 == (year % 4))
{ endQi = endQi + 1; }
if (qi < endQi)
return qi + 1;
return (year + 1) * 1000 + 1;
}
///
/// 获取上一期号
///
///
///
///
public static long GetLastQi(long qi, string lottery)
{
long year = qi / 1000;
long minQi = year * 1000 + 001;
long lastQi = qi - 1;
if (minQi > lastQi)
{
year = year - 1;
long endQi = year * 1000 + 153;
if (lottery == "3d" || lottery == "p3")
{
endQi = endQi + 205;
if (2014 == year)//2014年少一期
{ endQi = endQi - 1; }
}
if (0 == (year % 4))
{ endQi = endQi + 1; }
lastQi = endQi;
}
return lastQi;
}
///
/// 获取下一期号限制P3/3D
///
/// 必须为最新已开奖的期数
///
public static long GetLatestQi(long localQi)
{
int qi = Convert.ToInt32(localQi);
if (0 < qi)
{
DateTime now = DateTime.Now;
int year = qi / 1000;
DateTime sDate = new DateTime(year, 12, 31, 20, 30, 0);
DateTime eDate = new DateTime(year + 1, 1, 1, 20, 30, 0);
if (now > sDate && now < eDate)
{
qi = (year + 1) * 1000 + 1;
}
else
{
qi = qi + 1;
}
}
return qi;
}
}
}