• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef COMMON_COMPONENTS_BASE_TIME_UTILS_H
17 #define COMMON_COMPONENTS_BASE_TIME_UTILS_H
18 
19 #include <cinttypes>
20 
21 #include "common_components/base/c_string.h"
22 #include "common_interfaces/base/common.h"
23 
24 namespace common {
25 namespace TimeUtil {
26 // returns the monotonic time since epoch starting point in milliseconds
27 uint64_t MilliSeconds();
28 
29 // returns the monotonic time since epoch starting point in nanoseconds
30 PUBLIC_API uint64_t NanoSeconds();
31 
32 // returns the monotonic time since epoch starting point in microseconds
33 uint64_t MicroSeconds() noexcept;
34 
35 // sleep for the given count of nanoseconds
36 void SleepForNano(uint64_t ns);
37 
38 #ifndef NDEBUG
39 // returns the current date in ISO yyymmdd.hhmmss format
40 CString GetDigitDate();
41 #endif
42 
43 // returns the current date in ISO yyyy-mm-dd hh:mm::ss.ms format
44 PUBLIC_API CString GetTimestamp();
45 } // namespace TimeUtil
46 } // namespace common
47 
48 #endif // COMMON_COMPONENTS_BASE_TIME_UTILS_H
49