commit | author | age
|
a6c014
|
1 |
/* |
L |
2 |
* Copyright 2018 Google |
|
3 |
* |
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 |
* you may not use this file except in compliance with the License. |
|
6 |
* You may obtain a copy of the License at |
|
7 |
* |
|
8 |
* http://www.apache.org/licenses/LICENSE-2.0 |
|
9 |
* |
|
10 |
* Unless required by applicable law or agreed to in writing, software |
|
11 |
* distributed under the License is distributed on an "AS IS" BASIS, |
|
12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 |
* See the License for the specific language governing permissions and |
|
14 |
* limitations under the License. |
|
15 |
*/ |
|
16 |
|
|
17 |
#import <Foundation/Foundation.h> |
|
18 |
|
|
19 |
NS_ASSUME_NONNULL_BEGIN |
|
20 |
|
|
21 |
/** This class manages the device clock and produces snapshots of the current time. */ |
|
22 |
@interface GDTCORClock : NSObject <NSSecureCoding> |
|
23 |
|
|
24 |
/** The wallclock time, UTC, in milliseconds. */ |
|
25 |
@property(nonatomic, readonly) int64_t timeMillis; |
|
26 |
|
|
27 |
/** The offset from UTC in seconds. */ |
|
28 |
@property(nonatomic, readonly) int64_t timezoneOffsetSeconds; |
|
29 |
|
|
30 |
/** The kernel boot time when this clock was created in nanoseconds. */ |
|
31 |
@property(nonatomic, readonly) int64_t kernelBootTimeNanoseconds; |
|
32 |
|
|
33 |
/** The device uptime when this clock was created in nanoseconds. */ |
|
34 |
@property(nonatomic, readonly) int64_t uptimeNanoseconds; |
|
35 |
|
|
36 |
@property(nonatomic, readonly) int64_t kernelBootTime DEPRECATED_MSG_ATTRIBUTE( |
|
37 |
"Please use `kernelBootTimeNanoseconds` instead"); |
|
38 |
|
|
39 |
@property(nonatomic, readonly) |
|
40 |
int64_t uptime DEPRECATED_MSG_ATTRIBUTE("Please use `uptimeNanoseconds` instead"); |
|
41 |
|
|
42 |
/** Creates a GDTCORClock object using the current time and offsets. |
|
43 |
* |
|
44 |
* @return A new GDTCORClock object representing the current time state. |
|
45 |
*/ |
|
46 |
+ (instancetype)snapshot; |
|
47 |
|
|
48 |
/** Creates a GDTCORClock object representing a time in the future, relative to now. |
|
49 |
* |
|
50 |
* @param millisInTheFuture The millis in the future from now this clock should represent. |
|
51 |
* @return An instance representing a future time. |
|
52 |
*/ |
|
53 |
+ (instancetype)clockSnapshotInTheFuture:(uint64_t)millisInTheFuture; |
|
54 |
|
|
55 |
/** Compares one clock with another, returns YES if the caller is after the parameter. |
|
56 |
* |
|
57 |
* @return YES if the calling clock's time is after the given clock's time. |
|
58 |
*/ |
|
59 |
- (BOOL)isAfter:(GDTCORClock *)otherClock; |
|
60 |
|
|
61 |
/** Returns value of `uptime` property in milliseconds. */ |
|
62 |
- (int64_t)uptimeMilliseconds; |
|
63 |
|
|
64 |
@end |
|
65 |
|
|
66 |
NS_ASSUME_NONNULL_END |