mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Branch CEF3 files from /branches/cef3 to /trunk/cef3 (issue #564).
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@571 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
73
libcef/common/time_impl.cc
Normal file
73
libcef/common/time_impl.cc
Normal file
@ -0,0 +1,73 @@
|
||||
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#include "libcef/common/time_util.h"
|
||||
|
||||
void cef_time_to_basetime(const cef_time_t& cef_time, base::Time& time) {
|
||||
base::Time::Exploded exploded;
|
||||
exploded.year = cef_time.year;
|
||||
exploded.month = cef_time.month;
|
||||
#if !defined(OS_MACOSX)
|
||||
exploded.day_of_week = cef_time.day_of_week;
|
||||
#endif
|
||||
exploded.day_of_month = cef_time.day_of_month;
|
||||
exploded.hour = cef_time.hour;
|
||||
exploded.minute = cef_time.minute;
|
||||
exploded.second = cef_time.second;
|
||||
exploded.millisecond = cef_time.millisecond;
|
||||
time = base::Time::FromUTCExploded(exploded);
|
||||
}
|
||||
|
||||
void cef_time_from_basetime(const base::Time& time, cef_time_t& cef_time) {
|
||||
base::Time::Exploded exploded;
|
||||
time.UTCExplode(&exploded);
|
||||
cef_time.year = exploded.year;
|
||||
cef_time.month = exploded.month;
|
||||
#if !defined(OS_MACOSX)
|
||||
cef_time.day_of_week = exploded.day_of_week;
|
||||
#endif
|
||||
cef_time.day_of_month = exploded.day_of_month;
|
||||
cef_time.hour = exploded.hour;
|
||||
cef_time.minute = exploded.minute;
|
||||
cef_time.second = exploded.second;
|
||||
cef_time.millisecond = exploded.millisecond;
|
||||
}
|
||||
|
||||
CEF_EXPORT int cef_time_to_timet(const cef_time_t* cef_time, time_t* time) {
|
||||
if (!cef_time || !time)
|
||||
return 0;
|
||||
|
||||
base::Time base_time;
|
||||
cef_time_to_basetime(*cef_time, base_time);
|
||||
*time = base_time.ToTimeT();
|
||||
return 1;
|
||||
}
|
||||
|
||||
CEF_EXPORT int cef_time_from_timet(time_t time, cef_time_t* cef_time) {
|
||||
if (!cef_time)
|
||||
return 0;
|
||||
|
||||
base::Time base_time = base::Time::FromTimeT(time);
|
||||
cef_time_from_basetime(base_time, *cef_time);
|
||||
return 1;
|
||||
}
|
||||
|
||||
CEF_EXPORT int cef_time_to_doublet(const cef_time_t* cef_time, double* time) {
|
||||
if (!cef_time || !time)
|
||||
return 0;
|
||||
|
||||
base::Time base_time;
|
||||
cef_time_to_basetime(*cef_time, base_time);
|
||||
*time = base_time.ToDoubleT();
|
||||
return 1;
|
||||
}
|
||||
|
||||
CEF_EXPORT int cef_time_from_doublet(double time, cef_time_t* cef_time) {
|
||||
if (!cef_time)
|
||||
return 0;
|
||||
|
||||
base::Time base_time = base::Time::FromDoubleT(time);
|
||||
cef_time_from_basetime(base_time, *cef_time);
|
||||
return 1;
|
||||
}
|
Reference in New Issue
Block a user