]> git.saurik.com Git - apple/system_cmds.git/blob - CPPUtil/UtilAbsTime.cpp
system_cmds-643.30.1.tar.gz
[apple/system_cmds.git] / CPPUtil / UtilAbsTime.cpp
1 //
2 // UtilAbsTime.cpp
3 // CPPUtil
4 //
5 // Created by James McIlree on 4/14/13.
6 // Copyright (c) 2013 Apple. All rights reserved.
7 //
8
9 #include "CPPUtil.h"
10
11 BEGIN_UTIL_NAMESPACE
12
13 const AbsTime AbsTime::BEGINNING_OF_TIME = AbsTime(0ULL);
14 const AbsTime AbsTime::END_OF_TIME = AbsTime(UINT64_MAX);
15
16 AbsTime AbsTime::now() {
17 return AbsTime(mach_absolute_time());
18 }
19
20 NanoTime AbsTime::nano_time() const {
21 mach_timebase_info_data_t timebase_info;
22 mach_timebase_info(&timebase_info);
23 return NanoTime(_time * timebase_info.numer / timebase_info.denom);
24 }
25
26 NanoTime AbsTime::nano_time(mach_timebase_info_data_t timebase_info) const {
27 return NanoTime(_time * timebase_info.numer / timebase_info.denom);
28 }
29
30 END_UTIL_NAMESPACE