DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_CreateNewDocument() { CPDF_Document* pDoc = new CPDF_Document; pDoc->CreateNewDoc(); time_t currentTime; CFX_ByteString DateStr; if (FSDK_IsSandBoxPolicyEnabled(FPDF_POLICY_MACHINETIME_ACCESS)) { if (-1 != time(¤tTime)) { tm* pTM = localtime(¤tTime); if (pTM) { DateStr.Format("D:%04d%02d%02d%02d%02d%02d", pTM->tm_year + 1900, pTM->tm_mon + 1, pTM->tm_mday, pTM->tm_hour, pTM->tm_min, pTM->tm_sec); } } } CPDF_Dictionary* pInfoDict = NULL; pInfoDict = pDoc->GetInfo(); if (pInfoDict) { if (FSDK_IsSandBoxPolicyEnabled(FPDF_POLICY_MACHINETIME_ACCESS)) pInfoDict->SetAt("CreationDate", new CPDF_String(DateStr)); pInfoDict->SetAt("Creator", new CPDF_String(L"PDFium")); } return FPDFDocumentFromCPDFDocument(pDoc); }
double JS_GetDateTime() { if(!FSDK_IsSandBoxPolicyEnabled(FPDF_POLICY_MACHINETIME_ACCESS)) return 0; time_t t = time(NULL); struct tm* pTm = localtime(&t); int year = pTm->tm_year+1900; double t1 = _TimeFromYear(year); return t1 + pTm->tm_yday*86400000.0 + pTm->tm_hour*3600000.0+pTm->tm_min*60000.0+pTm->tm_sec*1000.0; }
int _getDaylightSavingTA(double d) { if(!FSDK_IsSandBoxPolicyEnabled(FPDF_POLICY_MACHINETIME_ACCESS)) return 0; time_t t = (time_t)(d/1000); struct tm * tmp = localtime(&t); if (tmp == NULL) return 0; if (tmp->tm_isdst > 0) //One hour. return (int)60*60*1000; return 0; }
double _getLocalTZA() { if(!FSDK_IsSandBoxPolicyEnabled(FPDF_POLICY_MACHINETIME_ACCESS)) return 0; time_t t = 0; time(&t); localtime(&t); #if _MSC_VER >= 1900 // In gcc and in Visual Studio prior to VS 2015 'timezone' is a global // variable declared in time.h. That variable was deprecated and in VS 2015 // is removed, with _get_timezone replacing it. long timezone = 0; _get_timezone(&timezone); #endif return (double)(-(timezone * 1000)); }