• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2011 Marshall A. Greenblatt. All rights reserved.
2 //
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are
5 // met:
6 //
7 //    * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer.
9 //    * Redistributions in binary form must reproduce the above
10 // copyright notice, this list of conditions and the following disclaimer
11 // in the documentation and/or other materials provided with the
12 // distribution.
13 //    * Neither the name of Google Inc. nor the name Chromium Embedded
14 // Framework nor the names of its contributors may be used to endorse
15 // or promote products derived from this software without specific prior
16 // written permission.
17 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 
30 #ifndef CEF_INCLUDE_INTERNAL_CEF_TIME_H_
31 #define CEF_INCLUDE_INTERNAL_CEF_TIME_H_
32 #pragma once
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 #include <time.h>
39 #include "include/internal/cef_export.h"
40 
41 ///
42 // Time information. Values should always be in UTC.
43 ///
44 typedef struct _cef_time_t {
45   int year;          // Four or five digit year "2007" (1601 to 30827 on
46                      //   Windows, 1970 to 2038 on 32-bit POSIX)
47   int month;         // 1-based month (values 1 = January, etc.)
48   int day_of_week;   // 0-based day of week (0 = Sunday, etc.)
49   int day_of_month;  // 1-based day of month (1-31)
50   int hour;          // Hour within the current day (0-23)
51   int minute;        // Minute within the current hour (0-59)
52   int second;        // Second within the current minute (0-59 plus leap
53                      //   seconds which may take it up to 60).
54   int millisecond;   // Milliseconds within the current second (0-999)
55 } cef_time_t;
56 
57 ///
58 // Converts cef_time_t to/from time_t. Returns true (1) on success and false (0)
59 // on failure.
60 ///
61 CEF_EXPORT int cef_time_to_timet(const cef_time_t* cef_time, time_t* time);
62 CEF_EXPORT int cef_time_from_timet(time_t time, cef_time_t* cef_time);
63 
64 ///
65 // Converts cef_time_t to/from a double which is the number of seconds since
66 // epoch (Jan 1, 1970). Webkit uses this format to represent time. A value of 0
67 // means "not initialized". Returns true (1) on success and false (0) on
68 // failure.
69 ///
70 CEF_EXPORT int cef_time_to_doublet(const cef_time_t* cef_time, double* time);
71 CEF_EXPORT int cef_time_from_doublet(double time, cef_time_t* cef_time);
72 
73 ///
74 // Retrieve the current system time.
75 //
76 CEF_EXPORT int cef_time_now(cef_time_t* cef_time);
77 
78 ///
79 // Retrieve the delta in milliseconds between two time values.
80 //
81 CEF_EXPORT int cef_time_delta(const cef_time_t* cef_time1,
82                               const cef_time_t* cef_time2,
83                               long long* delta);
84 
85 #ifdef __cplusplus
86 }
87 #endif
88 
89 #endif  // CEF_INCLUDE_INTERNAL_CEF_TIME_H_
90