MCPcopy Create free account
hub / github.com/abbeycode/UnrarKit / SetLocal

Method SetLocal

Libraries/unrar/timefn.cpp:70–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68
69
70void RarTime::SetLocal(RarLocalTime *lt)
71{
72#ifdef _WIN_ALL
73 SYSTEMTIME st;
74 st.wYear=lt->Year;
75 st.wMonth=lt->Month;
76 st.wDay=lt->Day;
77 st.wHour=lt->Hour;
78 st.wMinute=lt->Minute;
79 st.wSecond=lt->Second;
80 st.wMilliseconds=0;
81 st.wDayOfWeek=0;
82 FILETIME lft;
83 if (SystemTimeToFileTime(&st,&lft))
84 {
85 FILETIME ft;
86
87 if (WinNT() < WNT_VISTA)
88 {
89 // TzSpecificLocalTimeToSystemTime based code produces 1 hour error on XP.
90 LocalFileTimeToFileTime(&lft,&ft);
91 }
92 else
93 {
94 // Reverse procedure which we do in GetLocal.
95 SYSTEMTIME st1,st2;
96 FileTimeToSystemTime(&lft,&st2); // st2 might be unequal to st, because we added lt->Reminder to lft.
97 TzSpecificLocalTimeToSystemTime(NULL,&st2,&st1);
98 SystemTimeToFileTime(&st1,&ft);
99
100 // Correct precision loss (low 4 decimal digits) in FileTimeToSystemTime.
101 FILETIME rft;
102 SystemTimeToFileTime(&st2,&rft);
103 uint64 Corrected=INT32TO64(lft.dwHighDateTime,lft.dwLowDateTime)-
104 INT32TO64(rft.dwHighDateTime,rft.dwLowDateTime)+
105 INT32TO64(ft.dwHighDateTime,ft.dwLowDateTime);
106 ft.dwLowDateTime=(DWORD)Corrected;
107 ft.dwHighDateTime=(DWORD)(Corrected>>32);
108 }
109
110 SetWinFT(&ft);
111 }
112 else
113 Reset();
114#else
115 struct tm t;
116
117 t.tm_sec=lt->Second;
118 t.tm_min=lt->Minute;
119 t.tm_hour=lt->Hour;
120 t.tm_mday=lt->Day;
121 t.tm_mon=lt->Month-1;
122 t.tm_year=lt->Year-1900;
123 t.tm_isdst=-1;
124 SetUnix(mktime(&t));
125#endif
126 itime+=lt->Reminder;
127}

Callers 1

ReadHeader15Method · 0.80

Calls 1

WinNTFunction · 0.85

Tested by

no test coverage detected