如果需要用时间加密也可以参考
void zxptime::GetTime70(UINT tt,int timea)
{
UINT myear,mday,oday;
UINT msec;
UINT ttmonth[12]={
31,28,31,30,31,30,
31,31,30,31,30,31
};
tt+=(timea*3600);
mday=tt/(24*3600);
idayvale=mday;
msec=tt-mday*(24*3600);
myear=mday/365;
oday=mday-myear*365-(myear+1)/4;
int y, i=0;
UINT iimoth;
y=(1970+myear);
iimoth=((y%4==0)&&(y%100!=0))||(y%400==0);
for(i=0;i<12;i++)
{
if((y=oday-ttmonth[i])>=0)
oday-=ttmonth[i]+(i==1?iimoth:0);
else
break;
}
iday=oday+1;
imonth=i+1;
iyear=1970+myear;
ihour=msec/3600;
imin=(msec-ihour*3600)/60;
isec=msec%60;
};
void zxptime::GetTime900(UINT tt,int timea)
{
UINT myear,mday,oday;
UINT msec;
UINT ttmonth[12]={
31,28,31,30,31,30,
31,31,30,31,30,31
};
tt+=(timea*3600);// 中国8时区
mday=tt/(24*3600);
idayvale=mday-(70*365)-70/4;
msec=tt-mday*(24*3600);
myear=mday/365;
oday=mday-myear*365-(myear)/4;
int y, i=0;
UINT iimoth;
y=(1900+myear);
iimoth=((y%4==0)&&(y%100!=0))||(y%400==0);
for(i=0;i<12;i++)
{
if((y=oday-ttmonth[i])>=0)
oday-=ttmonth[i]+(i==1?iimoth:0);
else
break;
}
iday=oday+1;
imonth=i+1;
iyear=1900+myear;
ihour=msec/3600;
imin=(msec-ihour*3600)/60;
isec=msec%60;
};
- 标 题: 一个秒转换时间的c++小类,ntp可以用到,做时间转换可以参考
- 作 者:foolpanda
- 时 间:2007-03-15 22:39
- 链 接:http://bbs.pediy.com/showthread.php?t=41098