解锁时间生成与比较

Date_Unlock_Gen()

说明:假代码,用于生成解锁的时间节点。

unsigned int Date_Unlock_Comp()

说明:假代码,比较当前时间是否超过生成的时间节点,并返回是否进行解锁。

Date_Unlock_Gen()

{
//Define Lock_Minute
unsigned int Lock_Minute; //Max=255/3*15/60=21.25Hour
//Get Date_Now
unsigned int Year_Now=2022;
unsigned int Month_Now=8;
unsigned int Day_Now=9;
unsigned int Hour_Now=10;
unsigned int Minute_Now=42;
//Define Date_Unlock
unsigned int Year_Unlock;
unsigned int Month_Unlock;
unsigned int Day_Unlock;
unsigned int Hour_Unlock;
unsigned int Minute_Unlock;

static unsigned int Hour1_Unlock;
static unsigned int Day1_Unlock;

//Initiate date unlocked
Month_Unlock=Month_Now;
Day_Unlock=Day_Now;
Hour_Unlock=Hour_Now;
Minute_Unlock=Minute_Now;

Minute_Unlock=(Minute_Now+Lock_Minute)%60;
Hour1_Unlock=Hour_Now+(Minute_Now+Lock_Minute)/60;
Hour_Unlock=Hour1_Unlock%24;
Day1_Unlock=Day_Now+Hour1_Unlock/24;

if(Day1_Unlock>31&&(Month_Now==1||Month_Now==3||Month_Now==5||Month_Now==7||Month_Now==8||Month_Now==10||Month_Now==12))
{
    Day_Unlock=Day1_Unlock%31;
    Month_Unlock=Month_Now+Day1_Unlock/31;
    if(Month_Unlock>12)
    {
        Month_Unlock=Month_Unlock%12;
        Year_Unlock=Year_Now+Month_Unlock/12;
    }
}

if(Day1_Unlock>30&&(Month_Now==4||Month_Now==6||Month_Now==9||Month_Now==11))
{
    Day_Unlock=Day1_Unlock%30;
    Month_Unlock=Month_Now+Day1_Unlock/30;
}

if(Day1_Unlock>28&&(Month_Now==2))
{
    if(Year_Now%4==0)
    {
    Day_Unlock=Day1_Unlock%29;
    Month_Unlock=Month_Now+Day1_Unlock/29;
    }
    else
    {
    Day_Unlock=Day1_Unlock%28;
    Month_Unlock=Month_Now+Day1_Unlock/28;
    }  
}

}


unsigned int Date_Unlock_Comp()
{
unsigned int Unlock=0;
unsigned int Lock=1;
//Get Date_Now and Date_Unlock
unsigned int Year_Now=2022;
unsigned int Month_Now=8;
unsigned int Day_Now=9;
unsigned int Hour_Now=10;
unsigned int Minute_Now=42;

unsigned int Year_Unlock=2022;
unsigned int Month_Unlock=8;
unsigned int Day_Unlock=8;
unsigned int Hour_Unlock=8;
unsigned int Minute_Unlock=8;

//Compare
if(Year_Now>Year_Unlock)
return Unlock;
else
if(Month_Now>Month_Unlock)
return Unlock;
else
if(Day_Now>Day_Unlock)
return Unlock;
if(Hour_Now>Hour_Unlock)
return Unlock;
if(Minute_Now>Minute_Unlock)
return Unlock;
else
return Lock;

}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值