Fix timezone inconsistency in document methods test.
We do this by adding an override that forces GM time on
everyone when run from the test harness.
Generalize presubmit warnings so that the new function passes.
De-duplicate lambda capture in place of static function.
Change-Id: I15b34bea558baf1763476b36f0bca76614984107
Reviewed-on: https://pdfium-review.googlesource.com/c/44390
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/fpdfsdk/fpdf_editpage.cpp b/fpdfsdk/fpdf_editpage.cpp
index dcb3d5e..585e7e1 100644
--- a/fpdfsdk/fpdf_editpage.cpp
+++ b/fpdfsdk/fpdf_editpage.cpp
@@ -164,7 +164,7 @@
ByteString DateStr;
if (FSDK_IsSandBoxPolicyEnabled(FPDF_POLICY_MACHINETIME_ACCESS)) {
if (FXSYS_time(¤tTime) != -1) {
- tm* pTM = localtime(¤tTime);
+ tm* pTM = FXSYS_localtime(¤tTime);
if (pTM) {
DateStr = ByteString::Format(
"D:%04d%02d%02d%02d%02d%02d", pTM->tm_year + 1900, pTM->tm_mon + 1,
diff --git a/fpdfsdk/fpdf_ext.cpp b/fpdfsdk/fpdf_ext.cpp
index 1ff27cc..9f7b24b 100644
--- a/fpdfsdk/fpdf_ext.cpp
+++ b/fpdfsdk/fpdf_ext.cpp
@@ -83,6 +83,11 @@
FXSYS_SetTimeFunction(func);
}
+FPDF_EXPORT void FPDF_CALLCONV
+FSDK_SetLocaltimeFunction(struct tm* (*func)(const time_t* tp)) {
+ FXSYS_SetLocaltimeFunction(func);
+}
+
FPDF_EXPORT int FPDF_CALLCONV FPDFDoc_GetPageMode(FPDF_DOCUMENT document) {
CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
if (!pDoc)
diff --git a/fpdfsdk/fpdf_view_c_api_test.c b/fpdfsdk/fpdf_view_c_api_test.c
index ab184cc..9cf0376 100644
--- a/fpdfsdk/fpdf_view_c_api_test.c
+++ b/fpdfsdk/fpdf_view_c_api_test.c
@@ -216,6 +216,7 @@
// fpdf_ext.h
CHK(FPDFDoc_GetPageMode);
+ CHK(FSDK_SetLocaltimeFunction);
CHK(FSDK_SetTimeFunction);
CHK(FSDK_SetUnSpObjProcessHandler);