github.com/ckxng/wakeup@v0.0.0-20190105202853-90356a5f5a15/include/internal/cef_time.h (about)

     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 "include/internal/cef_export.h"
    39  #include <time.h>
    40  
    41  ///
    42  // Time information. Values should always be in UTC.
    43  ///
    44  typedef struct _cef_time_t {
    45    int year;          // Four digit year "2007"
    46    int month;         // 1-based month (values 1 = January, etc.)
    47    int day_of_week;   // 0-based day of week (0 = Sunday, etc.)
    48    int day_of_month;  // 1-based day of month (1-31)
    49    int hour;          // Hour within the current day (0-23)
    50    int minute;        // Minute within the current hour (0-59)
    51    int second;        // Second within the current minute (0-59 plus leap
    52                       //   seconds which may take it up to 60).
    53    int millisecond;   // Milliseconds within the current second (0-999)
    54  } cef_time_t;
    55  
    56  ///
    57  // Converts cef_time_t to/from time_t. Returns true (1) on success and false (0)
    58  // on failure.
    59  ///
    60  CEF_EXPORT int cef_time_to_timet(const cef_time_t* cef_time, time_t* time);
    61  CEF_EXPORT int cef_time_from_timet(time_t time, cef_time_t* cef_time);
    62  
    63  ///
    64  // Converts cef_time_t to/from a double which is the number of seconds since
    65  // epoch (Jan 1, 1970). Webkit uses this format to represent time. A value of 0
    66  // means "not initialized". Returns true (1) on success and false (0) on
    67  // failure.
    68  ///
    69  CEF_EXPORT int cef_time_to_doublet(const cef_time_t* cef_time, double* time);
    70  CEF_EXPORT int cef_time_from_doublet(double time, cef_time_t* cef_time);
    71  
    72  ///
    73  // Retrieve the current system time.
    74  //
    75  CEF_EXPORT int cef_time_now(cef_time_t* cef_time);
    76  
    77  ///
    78  // Retrieve the delta in milliseconds between two time values.
    79  //
    80  CEF_EXPORT int cef_time_delta(const cef_time_t* cef_time1,
    81                                const cef_time_t* cef_time2,
    82                                long long* delta);
    83  
    84  #ifdef __cplusplus
    85  }
    86  #endif
    87  
    88  #endif  // CEF_INCLUDE_INTERNAL_CEF_TIME_H_