#include "rar.hpp" RarTime::RarTime() { Reset(); } #ifdef _WIN_32 RarTime& RarTime::operator =(FILETIME &ft) { FILETIME lft,zft; FileTimeToLocalFileTime(&ft,&lft); SYSTEMTIME st; FileTimeToSystemTime(&lft,&st); rlt.Year=st.wYear; rlt.Month=st.wMonth; rlt.Day=st.wDay; rlt.Hour=st.wHour; rlt.Minute=st.wMinute; rlt.Second=st.wSecond; rlt.wDay=st.wDayOfWeek; rlt.yDay=rlt.Day-1; for (int I=1;I2 && IsLeapYear(rlt.Year)) rlt.yDay++; st.wMilliseconds=0; SystemTimeToFileTime(&st,&zft); rlt.Reminder=lft.dwLowDateTime-zft.dwLowDateTime; return(*this); } void RarTime::GetWin32(FILETIME *ft) { SYSTEMTIME st; st.wYear=rlt.Year; st.wMonth=rlt.Month; st.wDay=rlt.Day; st.wHour=rlt.Hour; st.wMinute=rlt.Minute; st.wSecond=rlt.Second; st.wMilliseconds=0; FILETIME lft; SystemTimeToFileTime(&st,&lft); lft.dwLowDateTime+=rlt.Reminder; if (lft.dwLowDateTime>32); ft.dwLowDateTime=int64to32(RawTime); *this=ft; #elif defined(_UNIX) || defined(_EMX) time_t ut=int64to32(RawTime/10000000); *this=ut; rlt.Reminder=int64to32(RawTime%10000000); #endif } #endif bool RarTime::operator == (RarTime &rt) { return(rlt.Year==rt.rlt.Year && rlt.Month==rt.rlt.Month && rlt.Day==rt.rlt.Day && rlt.Hour==rt.rlt.Hour && rlt.Minute==rt.rlt.Minute && rlt.Second==rt.rlt.Second && rlt.Reminder==rt.rlt.Reminder); } bool RarTime::operator < (RarTime &rt) { return(GetRaw() (RarTime &rt) { return(GetRaw()>rt.GetRaw()); } bool RarTime::operator >= (RarTime &rt) { return(*this>rt || *this==rt); } uint RarTime::GetDos() { uint DosTime=(rlt.Second/2)|(rlt.Minute<<5)|(rlt.Hour<<11)| (rlt.Day<<16)|(rlt.Month<<21)|((rlt.Year-1980)<<25); return(DosTime); } void RarTime::SetDos(uint DosTime) { rlt.Second=(DosTime & 0x1f)*2; rlt.Minute=(DosTime>>5) & 0x3f; rlt.Hour=(DosTime>>11) & 0x1f; rlt.Day=(DosTime>>16) & 0x1f; rlt.Month=(DosTime>>21) & 0x0f; rlt.Year=(DosTime>>25)+1980; rlt.Reminder=0; } #if !defined(GUI) || !defined(SFX_MODULE) void RarTime::GetText(char *DateStr,bool FullYear) { if (FullYear) sprintf(DateStr,"%02u-%02u-%u %02u:%02u",rlt.Day,rlt.Month,rlt.Year,rlt.Hour,rlt.Minute); else sprintf(DateStr,"%02u-%02u-%02u %02u:%02u",rlt.Day,rlt.Month,rlt.Year%100,rlt.Hour,rlt.Minute); } #endif #ifndef SFX_MODULE void RarTime::SetIsoText(char *TimeText) { int Field[6]; memset(Field,0,sizeof(Field)); for (int DigitCount=0;*TimeText!=0;TimeText++) if (isdigit(*TimeText)) { unsigned int FieldPos=DigitCount<4 ? 0:(DigitCount-4)/2+1; if (FieldPos