//年份表 uint code gYearTable[100] = {0, 366, 731, 1096, 1461, 1827, 2192, 2557, 2922, 3288, 3653, 4018, 4383, 4749, 5114, 5479, 5844, 6210, 6575, 6940, 7305, 7671, 8036, 8401, 8766, 9132, 9497, 9862,10227,10593, 10958,11323,11688,12054,12419,12784,13149,13515,13880,14245, 14610,14976,15341,15706,16071,16437,16802,17167,17532,17898, 18263,18628,18993,19359,19724,20089,20454,20820,21185,21550, 21915,22281,22646,23011,23376,23742,24107,24472,24837,25203, 25568,25933,26298,26664,27029,27394,27759,28125,28490,28855, 29220,29586,29951,30316,30681,31047,31412,31777,32142,32508, 32873,33238,33603,33969,34334,34699,35064,35430,35795,36160 };
//非闰年 uint code gMonthTable1[12] = {0,31,59,90,120,151,181,212,243,273,304,334}; //闰年 uint code gMonthTable2[12] = {0,31,60,91,121,152,182,213,244,274,305,335};
/*-------------------------------------------------------------------------- 功能: 将时间串转换成以2000起始的秒数 buf : year(1bcd),month,date,hour,minute,second --------------------------------------------------------------------------*/ ulong timestr2long(uchar *buf) { ulong tlong; uchar ch,ch1; ch = (buf[0]/16)*10+buf[0]%16; tlong = (ulong)((uint)gYearTable[ch]); ch1 = (buf[1]/16)*10+buf[1]%16; if(ch%4 == 0) tlong += (ulong)((uint)gMonthTable2[ch1-1]); else tlong += (ulong)((uint)gMonthTable1[ch1-1]); ch = (buf[2]/16)*10+buf[2]%16; tlong += (ulong)((uchar)(ch-1)); tlong *= 24; ch = (buf[3]/16)*10+buf[3]%16; tlong += (ulong)((uchar)ch); tlong *= 60; ch = (buf[4]/16)*10+buf[4]%16; tlong += (ulong)((uchar)ch); tlong *= 60; ch = (buf[5]/16)*10+buf[5]%16; tlong += (ulong)((uchar)ch); return tlong; } |