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 "xfa/fxfa/parser/xfa_localemgr.h" | 7 #include "xfa/fxfa/parser/xfa_localemgr.h" |
8 | 8 |
| 9 #include <time.h> |
| 10 |
9 #include <memory> | 11 #include <memory> |
10 #include <utility> | 12 #include <utility> |
11 | 13 |
12 #include "core/fxcodec/fx_codec.h" | 14 #include "core/fxcodec/fx_codec.h" |
13 #include "core/fxcrt/fx_xml.h" | 15 #include "core/fxcrt/fx_xml.h" |
14 #include "core/fxge/cfx_gemodule.h" | 16 #include "core/fxge/cfx_gemodule.h" |
15 #include "xfa/fxfa/parser/cxfa_document.h" | 17 #include "xfa/fxfa/parser/cxfa_document.h" |
16 #include "xfa/fxfa/parser/xfa_locale.h" | 18 #include "xfa/fxfa/parser/xfa_locale.h" |
17 #include "xfa/fxfa/parser/xfa_object.h" | 19 #include "xfa/fxfa/parser/xfa_object.h" |
18 #include "xfa/fxfa/parser/xfa_utils.h" | 20 #include "xfa/fxfa/parser/xfa_utils.h" |
(...skipping 1219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1238 : nullptr; | 1240 : nullptr; |
1239 if (pLocale) { | 1241 if (pLocale) { |
1240 pLocale->TryCData(XFA_ATTRIBUTE_Value, m_wsConfigLocale, false); | 1242 pLocale->TryCData(XFA_ATTRIBUTE_Value, m_wsConfigLocale, false); |
1241 } | 1243 } |
1242 } | 1244 } |
1243 m_dwLocaleFlags |= 0x01; | 1245 m_dwLocaleFlags |= 0x01; |
1244 } | 1246 } |
1245 return m_wsConfigLocale.AsStringC(); | 1247 return m_wsConfigLocale.AsStringC(); |
1246 } | 1248 } |
1247 | 1249 |
1248 static CXFA_TimeZoneProvider* g_pProvider = nullptr; | 1250 static bool g_bProviderTimeZoneSet = false; |
1249 | 1251 |
1250 // Static. | |
1251 CXFA_TimeZoneProvider* CXFA_TimeZoneProvider::Create() { | |
1252 ASSERT(!g_pProvider); | |
1253 g_pProvider = new CXFA_TimeZoneProvider(); | |
1254 return g_pProvider; | |
1255 } | |
1256 | |
1257 // Static. | |
1258 CXFA_TimeZoneProvider* CXFA_TimeZoneProvider::Get() { | |
1259 if (!g_pProvider) { | |
1260 g_pProvider = new CXFA_TimeZoneProvider(); | |
1261 } | |
1262 return g_pProvider; | |
1263 } | |
1264 | |
1265 // Static. | |
1266 void CXFA_TimeZoneProvider::Destroy() { | |
1267 delete g_pProvider; | |
1268 g_pProvider = nullptr; | |
1269 } | |
1270 | |
1271 #include <time.h> | |
1272 CXFA_TimeZoneProvider::CXFA_TimeZoneProvider() { | 1252 CXFA_TimeZoneProvider::CXFA_TimeZoneProvider() { |
1273 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 1253 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
1274 _tzset(); | 1254 if (!g_bProviderTimeZoneSet) { |
| 1255 g_bProviderTimeZoneSet = true; |
| 1256 _tzset(); |
| 1257 } |
1275 m_tz.tzHour = (int8_t)(_timezone / 3600 * -1); | 1258 m_tz.tzHour = (int8_t)(_timezone / 3600 * -1); |
1276 m_tz.tzMinute = (int8_t)((FXSYS_abs(_timezone) % 3600) / 60); | 1259 m_tz.tzMinute = (int8_t)((FXSYS_abs(_timezone) % 3600) / 60); |
1277 #else | 1260 #else |
1278 tzset(); | 1261 if (!g_bProviderTimeZoneSet) { |
| 1262 g_bProviderTimeZoneSet = true; |
| 1263 tzset(); |
| 1264 } |
1279 m_tz.tzHour = (int8_t)(timezone / 3600 * -1); | 1265 m_tz.tzHour = (int8_t)(timezone / 3600 * -1); |
1280 m_tz.tzMinute = (int8_t)((FXSYS_abs((int)timezone) % 3600) / 60); | 1266 m_tz.tzMinute = (int8_t)((FXSYS_abs((int)timezone) % 3600) / 60); |
1281 #endif | 1267 #endif |
1282 } | 1268 } |
1283 | 1269 |
1284 CXFA_TimeZoneProvider::~CXFA_TimeZoneProvider() {} | 1270 CXFA_TimeZoneProvider::~CXFA_TimeZoneProvider() {} |
1285 | 1271 |
1286 void CXFA_TimeZoneProvider::SetTimeZone(FX_TIMEZONE& tz) { | 1272 void CXFA_TimeZoneProvider::GetTimeZone(FX_TIMEZONE* tz) const { |
1287 m_tz = tz; | 1273 *tz = m_tz; |
1288 } | 1274 } |
1289 | |
1290 void CXFA_TimeZoneProvider::GetTimeZone(FX_TIMEZONE& tz) { | |
1291 tz = m_tz; | |
1292 } | |
OLD | NEW |