Skia
2DGraphicsLibrary
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SkTime.h
1 
2 /*
3  * Copyright 2006 The Android Open Source Project
4  *
5  * Use of this source code is governed by a BSD-style license that can be
6  * found in the LICENSE file.
7  */
8 
9 
10 #ifndef SkTime_DEFINED
11 #define SkTime_DEFINED
12 
13 #include "SkTypes.h"
14 
15 class SkString;
16 
20 class SK_API SkTime {
21 public:
22  struct DateTime {
23  int16_t fTimeZoneMinutes; // The number of minutes that GetDateTime()
24  // is ahead of or behind UTC.
25  uint16_t fYear;
26  uint8_t fMonth;
27  uint8_t fDayOfWeek;
28  uint8_t fDay;
29  uint8_t fHour;
30  uint8_t fMinute;
31  uint8_t fSecond;
32 
33  void toISO8601(SkString* dst) const;
34  };
35  static void GetDateTime(DateTime*);
36 
37  static double GetSecs() { return GetNSecs() * 1e-9; }
38  static double GetMSecs() { return GetNSecs() * 1e-6; }
39  static double GetNSecs();
40 };
41 
43 
44 class SkAutoTime {
45 public:
46  // The label is not deep-copied, so its address must remain valid for the
47  // lifetime of this object
48  SkAutoTime(const char* label = nullptr)
49  : fLabel(label)
50  , fNow(SkTime::GetMSecs()) {}
51  ~SkAutoTime() {
52  uint64_t dur = static_cast<uint64_t>(SkTime::GetMSecs() - fNow);
53  SkDebugf("%s %ld\n", fLabel ? fLabel : "", dur);
54  }
55 private:
56  const char* fLabel;
57  double fNow;
58 };
59 #define SkAutoTime(...) SK_REQUIRE_LOCAL_VAR(SkAutoTime)
60 
61 #endif
uint8_t fSecond
0..59
Definition: SkTime.h:31
Definition: SkTime.h:44
uint16_t fYear
e.g. 2005
Definition: SkTime.h:25
uint8_t fDayOfWeek
0..6, 0==Sunday
Definition: SkTime.h:27
uint8_t fHour
0..23
Definition: SkTime.h:29
uint8_t fMonth
1..12
Definition: SkTime.h:26
uint8_t fMinute
0..59
Definition: SkTime.h:30
uint8_t fDay
1..31
Definition: SkTime.h:28
Definition: SkTime.h:22
Platform-implemented utilities to return time of day, and millisecond counter.
Definition: SkTime.h:20
Light weight class for managing strings.
Definition: SkString.h:121