- Timestamp:
- May 22, 2018 12:35:20 PM (7 years ago)
- Location:
- trunk/src/VBox/Runtime
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/posix/timelocal-posix.cpp
r72163 r72285 148 148 149 149 /** 150 * Gets the delta between UTC and local time.150 * Gets the current delta between UTC and local time. 151 151 * 152 152 * @code … … 161 161 RTTIMESPEC Time; 162 162 return rtTimeLocalUTCOffset(RTTimeNow(&Time), true /* current time, skip fallback */); 163 } 164 165 166 /** 167 * Gets the delta between UTC and local time at the given time. 168 * 169 * @code 170 * RTTIMESPEC LocalTime; 171 * RTTimeNow(&LocalTime); 172 * RTTimeSpecAddNano(&LocalTime, RTTimeLocalDeltaNanoFor(&LocalTime)); 173 * @endcode 174 * 175 * @param pTimeSpec The time spec giving the time to get the delta for. 176 * @returns Returns the nanosecond delta between UTC and local time. 177 */ 178 RTDECL(int64_t) RTTimeLocalDeltaNanoFor(PCRTTIMESPEC pTimeSpec) 179 { 180 AssertPtr(pTimeSpec); 181 return rtTimeLocalUTCOffset(pTimeSpec, false /* current time, skip fallback */); 163 182 } 164 183 -
trunk/src/VBox/Runtime/r3/win/time2-win.cpp
r72163 r72285 107 107 } 108 108 109 110 /** 111 * Gets the delta between UTC and local time at the given time. 112 * 113 * @code 114 * RTTIMESPEC LocalTime; 115 * RTTimeNow(&LocalTime); 116 * RTTimeSpecAddNano(&LocalTime, RTTimeLocalDeltaNanoFor(&LocalTime)); 117 * @endcode 118 * 119 * @param pTimeSpec The time spec giving the time to get the delta for. 120 * @returns Returns the nanosecond delta between UTC and local time. 121 */ 122 RTDECL(int64_t) RTTimeLocalDeltaNanoFor(PCRTTIMESPEC pTimeSpec) 123 { 124 RTTIMESPEC LocalTime; 125 if (g_pfnSystemTimeToTzSpecificLocalTime) 126 { 127 /* 128 * FileTimeToLocalFileTime does not do the right thing, so we'll have 129 * to convert to system time and SystemTimeToTzSpecificLocalTime instead. 130 * 131 * Note! FileTimeToSystemTime drops resoultion down to milliseconds, thus 132 * we have to do the offUTC calculation using milliseconds and adjust 133 * u32Nanosecons by sub milliseconds digits. 134 */ 135 SYSTEMTIME SystemTimeIn; 136 FILETIME FileTime; 137 if (FileTimeToSystemTime(RTTimeSpecGetNtFileTime(pTimeSpec, &FileTime), &SystemTimeIn)) 138 { 139 SYSTEMTIME SystemTimeOut; 140 if (g_pfnSystemTimeToTzSpecificLocalTime(NULL /* use current TZI */, &SystemTimeIn, &SystemTimeOut)) 141 { 142 if (SystemTimeToFileTime(&SystemTimeOut, &FileTime)) 143 { 144 RTTimeSpecSetNtFileTime(&LocalTime, &FileTime); 145 146 return (RTTimeSpecGetMilli(&LocalTime) - RTTimeSpecGetMilli(pTimeSpec)) * RT_NS_1MS; 147 } 148 } 149 } 150 } 151 152 return RTTimeLocalDeltaNano(); 153 } 154
Note:
See TracChangeset
for help on using the changeset viewer.