1 /*
2  * Copyright (c) 2021 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 #include "platform/time/include/time.h"
17 
18 namespace OHOS {
19 namespace AI {
StepSleepMs(uint32_t milliseconds)20 void StepSleepMs(uint32_t milliseconds)
21 {
22     std::this_thread::sleep_for(std::chrono::milliseconds(milliseconds));
23 }
24 
GetCurTimeSec()25 time_t GetCurTimeSec()
26 {
27     std::chrono::system_clock::duration d = std::chrono::system_clock::now().time_since_epoch();
28     std::chrono::seconds sec = std::chrono::duration_cast<std::chrono::seconds>(d);
29     return sec.count();
30 }
31 
GetCurTimeMillSec()32 time_t GetCurTimeMillSec()
33 {
34     std::chrono::system_clock::duration d = std::chrono::system_clock::now().time_since_epoch();
35     std::chrono::milliseconds sec = std::chrono::duration_cast<std::chrono::milliseconds>(d);
36     return sec.count();
37 }
38 } // namespace AI
39 } // namespace OHOS