1 // Copyright 2017 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 
7 #include "xfa/fxfa/parser/cxfa_timezoneprovider.h"
8 
9 #include <time.h>
10 
11 #include "build/build_config.h"
12 
13 static bool g_bProviderTimeZoneSet = false;
14 
CXFA_TimeZoneProvider()15 CXFA_TimeZoneProvider::CXFA_TimeZoneProvider() {
16 #if defined(OS_WIN)
17   if (!g_bProviderTimeZoneSet) {
18     g_bProviderTimeZoneSet = true;
19     _tzset();
20   }
21   m_tz.tzHour = static_cast<int8_t>(_timezone / 3600 * -1);
22   m_tz.tzMinute = static_cast<int8_t>((abs(_timezone) % 3600) / 60);
23 #else
24   if (!g_bProviderTimeZoneSet) {
25     g_bProviderTimeZoneSet = true;
26     tzset();
27   }
28   m_tz.tzHour = static_cast<int8_t>(timezone / 3600 * -1);
29   m_tz.tzMinute =
30       static_cast<int8_t>((abs(static_cast<int>(timezone)) % 3600) / 60);
31 #endif
32 }
33 
~CXFA_TimeZoneProvider()34 CXFA_TimeZoneProvider::~CXFA_TimeZoneProvider() {}
35