1 // Copyright 2018 The PDFium Authors 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 #ifndef FXJS_FX_DATE_HELPERS_H_ 8 #define FXJS_FX_DATE_HELPERS_H_ 9 10 #include <stddef.h> 11 12 #include "core/fxcrt/widestring.h" 13 14 namespace fxjs { 15 16 enum class ConversionStatus { kSuccess = 0, kBadFormat, kBadDate }; 17 18 extern const wchar_t* const kMonths[12]; 19 extern const wchar_t* const kFullMonths[12]; 20 21 double FX_GetDateTime(); 22 int FX_GetYearFromTime(double dt); 23 int FX_GetMonthFromTime(double dt); 24 int FX_GetDayFromTime(double dt); 25 int FX_GetHourFromTime(double dt); 26 int FX_GetMinFromTime(double dt); 27 int FX_GetSecFromTime(double dt); 28 bool FX_IsValidMonth(int m); 29 bool FX_IsValidDay(int d); 30 bool FX_IsValid24Hour(int h); 31 bool FX_IsValidMinute(int m); 32 bool FX_IsValidSecond(int s); 33 double FX_LocalTime(double d); 34 double FX_MakeDay(int nYear, int nMonth, int nDay); 35 double FX_MakeTime(int nHour, int nMin, int nSec, int nMs); 36 double FX_MakeDate(double day, double time); 37 38 int FX_ParseStringInteger(const WideString& str, 39 size_t nStart, 40 size_t* pSkip, 41 size_t nMaxStep); 42 43 ConversionStatus FX_ParseDateUsingFormat(const WideString& value, 44 const WideString& format, 45 double* result); 46 47 } // namespace fxjs 48 49 using fxjs::FX_GetDateTime; 50 using fxjs::FX_GetDayFromTime; 51 using fxjs::FX_GetHourFromTime; 52 using fxjs::FX_GetMinFromTime; 53 using fxjs::FX_GetMonthFromTime; 54 using fxjs::FX_GetSecFromTime; 55 using fxjs::FX_GetYearFromTime; 56 using fxjs::FX_IsValid24Hour; 57 using fxjs::FX_IsValidDay; 58 using fxjs::FX_IsValidMinute; 59 using fxjs::FX_IsValidMonth; 60 using fxjs::FX_IsValidSecond; 61 using fxjs::FX_LocalTime; 62 using fxjs::FX_MakeDate; 63 using fxjs::FX_MakeDay; 64 using fxjs::FX_MakeTime; 65 using fxjs::FX_ParseDateUsingFormat; 66 using fxjs::FX_ParseStringInteger; 67 68 #endif // FXJS_FX_DATE_HELPERS_H_ 69