| 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 "JS_Value.h" | 7 #include "JS_Value.h" |
| 8 | 8 |
| 9 #include <time.h> | 9 #include <time.h> |
| 10 #include <cmath> | 10 #include <cmath> |
| (...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 604 _get_timezone(&timezone); | 604 _get_timezone(&timezone); |
| 605 #endif | 605 #endif |
| 606 return (double)(-(timezone * 1000)); | 606 return (double)(-(timezone * 1000)); |
| 607 } | 607 } |
| 608 | 608 |
| 609 int _getDaylightSavingTA(double d) { | 609 int _getDaylightSavingTA(double d) { |
| 610 if (!FSDK_IsSandBoxPolicyEnabled(FPDF_POLICY_MACHINETIME_ACCESS)) | 610 if (!FSDK_IsSandBoxPolicyEnabled(FPDF_POLICY_MACHINETIME_ACCESS)) |
| 611 return 0; | 611 return 0; |
| 612 time_t t = (time_t)(d / 1000); | 612 time_t t = (time_t)(d / 1000); |
| 613 struct tm* tmp = localtime(&t); | 613 struct tm* tmp = localtime(&t); |
| 614 if (tmp == NULL) | 614 if (!tmp) |
| 615 return 0; | 615 return 0; |
| 616 if (tmp->tm_isdst > 0) | 616 if (tmp->tm_isdst > 0) |
| 617 // One hour. | 617 // One hour. |
| 618 return (int)60 * 60 * 1000; | 618 return (int)60 * 60 * 1000; |
| 619 return 0; | 619 return 0; |
| 620 } | 620 } |
| 621 | 621 |
| 622 double _Mod(double x, double y) { | 622 double _Mod(double x, double y) { |
| 623 double r = fmod(x, y); | 623 double r = fmod(x, y); |
| 624 if (r < 0) | 624 if (r < 0) |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 862 return day * 86400000 + time; | 862 return day * 86400000 + time; |
| 863 } | 863 } |
| 864 | 864 |
| 865 bool JS_PortIsNan(double d) { | 865 bool JS_PortIsNan(double d) { |
| 866 return d != d; | 866 return d != d; |
| 867 } | 867 } |
| 868 | 868 |
| 869 double JS_LocalTime(double d) { | 869 double JS_LocalTime(double d) { |
| 870 return JS_GetDateTime() + _getDaylightSavingTA(d); | 870 return JS_GetDateTime() + _getDaylightSavingTA(d); |
| 871 } | 871 } |
| OLD | NEW |