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