Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(665)

Side by Side Diff: chrome/browser/sync/notifier/base/posix/time_posix.cc

Issue 194065: Initial commit of sync engine code to browser/sync.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Fixes to gtest include path, reverted syncapi. Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <assert.h>
6 #include <sys/time.h>
7 #include <stdlib.h>
8 #include <string.h>
9
10 #include "chrome/browser/sync/notifier/base/time.h"
11
12 namespace notifier {
13
14 time64 GetCurrent100NSTime() {
15 struct timeval tv;
16 struct timezone tz;
17
18 gettimeofday(&tv, &tz);
19
20 time64 retval = tv.tv_sec * kSecsTo100ns;
21 retval += tv.tv_usec * kMicrosecsTo100ns;
22 retval += kStart100NsTimeToEpoch;
23 return retval;
24 }
25
26 time64 TmToTime64(const struct tm& tm) {
27 struct tm tm_temp;
28 memcpy(&tm_temp, &tm, sizeof(struct tm));
29 time_t t = timegm(&tm_temp);
30 return t * kSecsTo100ns;
31 }
32
33 bool Time64ToTm(time64 t, struct tm* tm) {
34 assert(tm != NULL);
35 time_t secs = t / kSecsTo100ns;
36 gmtime_r(&secs, tm);
37 return true;
38 }
39
40 bool UtcTimeToLocalTime(struct tm* tm) {
41 assert(tm != NULL);
42 time_t t = timegm(tm);
43 localtime_r(&t, tm);
44 return true;
45 }
46
47 bool LocalTimeToUtcTime(struct tm* tm) {
48 assert(tm != NULL);
49 time_t t = mktime(tm);
50 gmtime_r(&t, tm);
51 return true;
52 }
53
54 } // namespace notifier
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698