| 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/fm2js/xfa_fm2jscontext.h" | 7 #include "xfa/fxfa/fm2js/xfa_fm2jscontext.h" |
| 8 | 8 |
| 9 #include <time.h> | 9 #include <time.h> |
| 10 | 10 |
| (...skipping 1164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1175 return; | 1175 return; |
| 1176 } | 1176 } |
| 1177 | 1177 |
| 1178 CFX_Unitime uniTime = timeValue.GetTime(); | 1178 CFX_Unitime uniTime = timeValue.GetTime(); |
| 1179 int32_t hour = uniTime.GetHour(); | 1179 int32_t hour = uniTime.GetHour(); |
| 1180 int32_t min = uniTime.GetMinute(); | 1180 int32_t min = uniTime.GetMinute(); |
| 1181 int32_t second = uniTime.GetSecond(); | 1181 int32_t second = uniTime.GetSecond(); |
| 1182 int32_t milSecond = uniTime.GetMillisecond(); | 1182 int32_t milSecond = uniTime.GetMillisecond(); |
| 1183 | 1183 |
| 1184 FX_TIMEZONE tzLocale; | 1184 FX_TIMEZONE tzLocale; |
| 1185 pMgr->GetDefLocale()->GetTimeZone(tzLocale); | 1185 pMgr->GetDefLocale()->GetTimeZone(&tzLocale); |
| 1186 | 1186 |
| 1187 // TODO(dsinclair): See if there is other time conversion code in pdfium and | 1187 // TODO(dsinclair): See if there is other time conversion code in pdfium and |
| 1188 // consolidate. | 1188 // consolidate. |
| 1189 int32_t mins = hour * 60 + min; | 1189 int32_t mins = hour * 60 + min; |
| 1190 mins -= (tzLocale.tzHour * 60); | 1190 mins -= (tzLocale.tzHour * 60); |
| 1191 while (mins > 1440) | 1191 while (mins > 1440) |
| 1192 mins -= 1440; | 1192 mins -= 1440; |
| 1193 while (mins < 0) | 1193 while (mins < 0) |
| 1194 mins += 1440; | 1194 mins += 1440; |
| 1195 hour = mins / 60; | 1195 hour = mins / 60; |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1598 args.GetReturnValue()->SetInteger(0); | 1598 args.GetReturnValue()->SetInteger(0); |
| 1599 return; | 1599 return; |
| 1600 } | 1600 } |
| 1601 | 1601 |
| 1602 CFX_Unitime uniTime = localeValue.GetTime(); | 1602 CFX_Unitime uniTime = localeValue.GetTime(); |
| 1603 int32_t hour = uniTime.GetHour(); | 1603 int32_t hour = uniTime.GetHour(); |
| 1604 int32_t min = uniTime.GetMinute(); | 1604 int32_t min = uniTime.GetMinute(); |
| 1605 int32_t second = uniTime.GetSecond(); | 1605 int32_t second = uniTime.GetSecond(); |
| 1606 int32_t milSecond = uniTime.GetMillisecond(); | 1606 int32_t milSecond = uniTime.GetMillisecond(); |
| 1607 int32_t mins = hour * 60 + min; | 1607 int32_t mins = hour * 60 + min; |
| 1608 CXFA_TimeZoneProvider* pProvider = CXFA_TimeZoneProvider::Get(); | |
| 1609 if (pProvider) { | |
| 1610 FX_TIMEZONE tz; | |
| 1611 pProvider->GetTimeZone(tz); | |
| 1612 mins -= (tz.tzHour * 60); | |
| 1613 while (mins > 1440) | |
| 1614 mins -= 1440; | |
| 1615 while (mins < 0) | |
| 1616 mins += 1440; | |
| 1617 | 1608 |
| 1618 hour = mins / 60; | 1609 FX_TIMEZONE tz; |
| 1619 min = mins % 60; | 1610 CXFA_TimeZoneProvider provider; |
| 1620 } | 1611 provider.GetTimeZone(&tz); |
| 1612 mins -= (tz.tzHour * 60); |
| 1613 while (mins > 1440) |
| 1614 mins -= 1440; |
| 1615 |
| 1616 while (mins < 0) |
| 1617 mins += 1440; |
| 1618 |
| 1619 hour = mins / 60; |
| 1620 min = mins % 60; |
| 1621 args.GetReturnValue()->SetInteger(hour * 3600000 + min * 60000 + | 1621 args.GetReturnValue()->SetInteger(hour * 3600000 + min * 60000 + |
| 1622 second * 1000 + milSecond + 1); | 1622 second * 1000 + milSecond + 1); |
| 1623 } | 1623 } |
| 1624 | 1624 |
| 1625 // static | 1625 // static |
| 1626 void CXFA_FM2JSContext::TimeFmt(CFXJSE_Value* pThis, | 1626 void CXFA_FM2JSContext::TimeFmt(CFXJSE_Value* pThis, |
| 1627 const CFX_ByteStringC& szFuncName, | 1627 const CFX_ByteStringC& szFuncName, |
| 1628 CFXJSE_Arguments& args) { | 1628 CFXJSE_Arguments& args) { |
| 1629 int32_t argc = args.GetLength(); | 1629 int32_t argc = args.GetLength(); |
| 1630 if (argc > 2) { | 1630 if (argc > 2) { |
| (...skipping 4887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6518 CFX_WideString wsFormat; | 6518 CFX_WideString wsFormat; |
| 6519 pAppProvider->LoadString(iStringID, wsFormat); | 6519 pAppProvider->LoadString(iStringID, wsFormat); |
| 6520 CFX_WideString wsMessage; | 6520 CFX_WideString wsMessage; |
| 6521 va_list arg_ptr; | 6521 va_list arg_ptr; |
| 6522 va_start(arg_ptr, iStringID); | 6522 va_start(arg_ptr, iStringID); |
| 6523 wsMessage.FormatV(wsFormat.c_str(), arg_ptr); | 6523 wsMessage.FormatV(wsFormat.c_str(), arg_ptr); |
| 6524 va_end(arg_ptr); | 6524 va_end(arg_ptr); |
| 6525 FXJSE_ThrowMessage( | 6525 FXJSE_ThrowMessage( |
| 6526 FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); | 6526 FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); |
| 6527 } | 6527 } |
| OLD | NEW |