B
bjaman
Unregistered / Unconfirmed
GUEST, unregistred user!
C代码:
String CompactCipherTime(TDateTime DT)
{
String Scipher;
char Buffer[16];
DWORD dw;
Word Year, Month, Day, Hour, Min, Sec, MSec;
DecodeDate(DT, Year, Month, Day);
DecodeTime(DT, Hour, Min, Sec, MSec);
dw=((Sec&63)>>1)+((Min&63)<<5)+((Hour&31)<<11)+((Day&31)<<16)+((Month&15)<<21)+(((Year % 1000)&127)<<25);
itoa(dw,Buffer,16);
for(int i=0;i<8;i++)
Buffer=UpCase(Buffer);
Scipher=Buffer;
return(Scipher);
}
翻译过来的Delphi代码:
function CompactCipherTime(aDateTime :TDateTime) : string;
var
dw : LongWord;
Year,Month,Day,Hour,Min,Sec,MSec : word;
Buffer : string;
begin
DecodeDate(aDateTime,Year,Month,Day);
DecodeTime(aDateTime,Hour,Min,Sec,MSec);
dw := ((Sec and 63) shr 1) + ((Min and 63) shl 5) + ((Hour and 31) shl 11) +
((Day and 31) shl 16) + ((Month and 15) shl 21) + (((Year mod 1000) and 127) shl 25);
Buffer := UpperCase(IntToStr(dw));
Buffer := Copy(Buffer,1,8);
Result := Buffer;
end;
String CompactCipherTime(TDateTime DT)
{
String Scipher;
char Buffer[16];
DWORD dw;
Word Year, Month, Day, Hour, Min, Sec, MSec;
DecodeDate(DT, Year, Month, Day);
DecodeTime(DT, Hour, Min, Sec, MSec);
dw=((Sec&63)>>1)+((Min&63)<<5)+((Hour&31)<<11)+((Day&31)<<16)+((Month&15)<<21)+(((Year % 1000)&127)<<25);
itoa(dw,Buffer,16);
for(int i=0;i<8;i++)
Buffer=UpCase(Buffer);
Scipher=Buffer;
return(Scipher);
}
翻译过来的Delphi代码:
function CompactCipherTime(aDateTime :TDateTime) : string;
var
dw : LongWord;
Year,Month,Day,Hour,Min,Sec,MSec : word;
Buffer : string;
begin
DecodeDate(aDateTime,Year,Month,Day);
DecodeTime(aDateTime,Hour,Min,Sec,MSec);
dw := ((Sec and 63) shr 1) + ((Min and 63) shl 5) + ((Hour and 31) shl 11) +
((Day and 31) shl 16) + ((Month and 15) shl 21) + (((Year mod 1000) and 127) shl 25);
Buffer := UpperCase(IntToStr(dw));
Buffer := Copy(Buffer,1,8);
Result := Buffer;
end;