Changeset 72285 in vbox
- Timestamp:
- May 22, 2018 12:35:20 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 122734
- Location:
- trunk
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/mangling.h
r72140 r72285 2264 2264 # define RTTimeIsLeapYear RT_MANGLER(RTTimeIsLeapYear) 2265 2265 # define RTTimeLocalDeltaNano RT_MANGLER(RTTimeLocalDeltaNano) 2266 # define RTTimeLocalDeltaNanoFor RT_MANGLER(RTTimeLocalDeltaNanoFor) 2266 2267 # define RTTimeLocalExplode RT_MANGLER(RTTimeLocalExplode) 2267 2268 # define RTTimeLocalNormalize RT_MANGLER(RTTimeLocalNormalize) -
trunk/include/iprt/time.h
r72165 r72285 723 723 724 724 /** 725 * Gets the delta between UTC and local time.725 * Gets the current delta between UTC and local time. 726 726 * 727 727 * @code … … 733 733 */ 734 734 RTDECL(int64_t) RTTimeLocalDeltaNano(void); 735 736 /** 737 * Gets the delta between UTC and local time at the given time. 738 * 739 * @code 740 * RTTIMESPEC LocalTime; 741 * RTTimeNow(&LocalTime); 742 * RTTimeSpecAddNano(&LocalTime, RTTimeLocalDeltaNanoFor(&LocalTime)); 743 * @endcode 744 * 745 * @param pTimeSpec The time spec giving the time to get the delta for. 746 * @returns Returns the nanosecond delta between UTC and local time. 747 */ 748 RTDECL(int64_t) RTTimeLocalDeltaNanoFor(PCRTTIMESPEC pTimeSpec); 735 749 736 750 /** -
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.