| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "core/fxcrt/include/fx_system.h" | 7 #include "core/fxcrt/include/fx_system.h" |
| 8 #include "xfa/fgas/localization/fgas_datetime.h" | 8 #include "xfa/fgas/localization/fgas_datetime.h" |
| 9 | 9 |
| 10 #if _FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_ANDROID_ || \ | 10 #if _FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_ANDROID_ || \ |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 }; | 135 }; |
| 136 | 136 |
| 137 void CFX_Unitime::Now() { | 137 void CFX_Unitime::Now() { |
| 138 FXUT_SYSTEMTIME utLocal; | 138 FXUT_SYSTEMTIME utLocal; |
| 139 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || \ | 139 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || \ |
| 140 _FX_OS_ == _FX_WIN64_ | 140 _FX_OS_ == _FX_WIN64_ |
| 141 ::GetLocalTime((LPSYSTEMTIME)&utLocal); | 141 ::GetLocalTime((LPSYSTEMTIME)&utLocal); |
| 142 #elif _FX_OS_ != _FX_EMBEDDED_ | 142 #elif _FX_OS_ != _FX_EMBEDDED_ |
| 143 #if 1 | 143 #if 1 |
| 144 timeval curTime; | 144 timeval curTime; |
| 145 gettimeofday(&curTime, NULL); | 145 gettimeofday(&curTime, nullptr); |
| 146 #else | 146 #else |
| 147 struct timespec curTime; | 147 struct timespec curTime; |
| 148 clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &curTime); | 148 clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &curTime); |
| 149 #endif | 149 #endif |
| 150 struct tm st; | 150 struct tm st; |
| 151 localtime_r(&curTime.tv_sec, &st); | 151 localtime_r(&curTime.tv_sec, &st); |
| 152 utLocal.wYear = st.tm_year + 1900; | 152 utLocal.wYear = st.tm_year + 1900; |
| 153 utLocal.wMonth = st.tm_mon + 1; | 153 utLocal.wMonth = st.tm_mon + 1; |
| 154 utLocal.wDayOfWeek = st.tm_wday; | 154 utLocal.wDayOfWeek = st.tm_wday; |
| 155 utLocal.wDay = st.tm_mday; | 155 utLocal.wDay = st.tm_mday; |
| 156 utLocal.wHour = st.tm_hour; | 156 utLocal.wHour = st.tm_hour; |
| 157 utLocal.wMinute = st.tm_min; | 157 utLocal.wMinute = st.tm_min; |
| 158 utLocal.wSecond = st.tm_sec; | 158 utLocal.wSecond = st.tm_sec; |
| 159 utLocal.wMilliseconds = curTime.tv_usec / 1000; | 159 utLocal.wMilliseconds = curTime.tv_usec / 1000; |
| 160 #endif | 160 #endif |
| 161 Set(utLocal.wYear, (uint8_t)utLocal.wMonth, (uint8_t)utLocal.wDay, | 161 Set(utLocal.wYear, (uint8_t)utLocal.wMonth, (uint8_t)utLocal.wDay, |
| 162 (uint8_t)utLocal.wHour, (uint8_t)utLocal.wMinute, | 162 (uint8_t)utLocal.wHour, (uint8_t)utLocal.wMinute, |
| 163 (uint8_t)utLocal.wSecond, (uint16_t)utLocal.wMilliseconds); | 163 (uint8_t)utLocal.wSecond, (uint16_t)utLocal.wMilliseconds); |
| 164 } | 164 } |
| 165 void CFX_Unitime::SetGMTime() { | 165 void CFX_Unitime::SetGMTime() { |
| 166 FXUT_SYSTEMTIME utLocal; | 166 FXUT_SYSTEMTIME utLocal; |
| 167 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || \ | 167 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || \ |
| 168 _FX_OS_ == _FX_WIN64_ | 168 _FX_OS_ == _FX_WIN64_ |
| 169 ::GetSystemTime((LPSYSTEMTIME)&utLocal); | 169 ::GetSystemTime((LPSYSTEMTIME)&utLocal); |
| 170 #elif _FX_OS_ != _FX_EMBEDDED_ | 170 #elif _FX_OS_ != _FX_EMBEDDED_ |
| 171 #if 1 | 171 #if 1 |
| 172 timeval curTime; | 172 timeval curTime; |
| 173 gettimeofday(&curTime, NULL); | 173 gettimeofday(&curTime, nullptr); |
| 174 #else | 174 #else |
| 175 struct timespec curTime; | 175 struct timespec curTime; |
| 176 clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &curTime); | 176 clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &curTime); |
| 177 #endif | 177 #endif |
| 178 struct tm st; | 178 struct tm st; |
| 179 gmtime_r(&curTime.tv_sec, &st); | 179 gmtime_r(&curTime.tv_sec, &st); |
| 180 utLocal.wYear = st.tm_year + 1900; | 180 utLocal.wYear = st.tm_year + 1900; |
| 181 utLocal.wMonth = st.tm_mon + 1; | 181 utLocal.wMonth = st.tm_mon + 1; |
| 182 utLocal.wDayOfWeek = st.tm_wday; | 182 utLocal.wDayOfWeek = st.tm_wday; |
| 183 utLocal.wDay = st.tm_mday; | 183 utLocal.wDay = st.tm_mday; |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 iMilliseconds %= g_FXMillisecondsPerSecond; | 541 iMilliseconds %= g_FXMillisecondsPerSecond; |
| 542 if (iMilliseconds < 0) { | 542 if (iMilliseconds < 0) { |
| 543 iSeconds--, iMilliseconds += g_FXMillisecondsPerSecond; | 543 iSeconds--, iMilliseconds += g_FXMillisecondsPerSecond; |
| 544 } | 544 } |
| 545 m_DateTime.Time.sTime.millisecond = (uint16_t)iMilliseconds; | 545 m_DateTime.Time.sTime.millisecond = (uint16_t)iMilliseconds; |
| 546 if (iSeconds != 0) { | 546 if (iSeconds != 0) { |
| 547 AddSeconds(iSeconds); | 547 AddSeconds(iSeconds); |
| 548 } | 548 } |
| 549 return TRUE; | 549 return TRUE; |
| 550 } | 550 } |
| OLD | NEW |