From d3840c278255b138b801c92b11cc20b3d250b989 Mon Sep 17 00:00:00 2001 From: peilixia Date: Sat, 28 Jan 2023 15:07:39 +0800 Subject: [PATCH] Add guide for datetime_ex.h Issue:I6BBG1 Test:NA --- docs/zh-cn/c-utils-guide-datetime.md | 35 ++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 docs/zh-cn/c-utils-guide-datetime.md diff --git a/docs/zh-cn/c-utils-guide-datetime.md b/docs/zh-cn/c-utils-guide-datetime.md new file mode 100644 index 0000000..4edb53a --- /dev/null +++ b/docs/zh-cn/c-utils-guide-datetime.md @@ -0,0 +1,35 @@ +# 时间操作 + +## 概述 + +### 简介 +提供一些时间的相关操作的能力增强接口。包括时间转换,获取天数和获取时区等函数。 + +## 接口说明 +|返回类型 |名称 | +| :------------ | :------------ | +|int64_t |**SecToNanosec**(int64_t sec)
将秒数转换为纳秒数。 | +|int64_t |**MillisecToNanosec**(int64_t millise)
将毫秒数转换为纳秒数。 | +|int64_t |**MicrosecToNanosec**(int64_t microsec)
将微秒数转换为纳秒数。 | +|int64_t |**NanosecToSec**(int64_t nanosec)
将纳秒数转换为秒数。 | +|int64_t |**NanosecToMillisec**(int64_t nanosec)
将纳秒数转换为毫秒数。 | +|int64_t |**NanosecToMicrosec**(int64_t nanosec)
将纳秒数转换为微秒数。 | +|int64_t |**GetSecondsSince1970ToNow**()
获取从 1970 年到现在的秒数。 | +|int64_t |**GetSecondsSince1970ToPointTime**(struct tm inputTm)
获取从 1970 到输入时间的秒数。 | +|int64_t |**GetSecondsBetween**(struct tm inputTm1, struct tm inputTm2)
获取 inputTm1 和 inputTm2 之间的秒数。 | +|int64_t |**GetDaysSince1970ToNow**()
获取从 1970 年到现在的天数。 | +|bool |**GetLocalTimeZone**(int& timezone)
获取当前时区。 | +|bool |**GetSystemCurrentTime**(struct tm* curTime)
获取当前时间。 | +|int64_t |**GetTickCount**()
获取自系统启动以来的毫秒数。 | +|int64_t |**GetMicroTickCount**()
获取自系统启动以来的微秒数。 | + +## 使用示例 +1. 测试用例编译运行方法 + +1.1 使用开发者自测试框架,使用方法参见:[开发自测试执行框架-测试用例执行](https://gitee.com/openharmony/testfwk_developer_test#%E6%B5%8B%E8%AF%95%E7%94%A8%E4%BE%8B%E6%89%A7%E8%A1%8C) + +1.2 使用以下具体命令以运行`datetime_ex.h`对应测试用例 + +\`\`\`bash +run -t UT -tp utils -ts UtilsDateTimeTest +\`\`\` \ No newline at end of file -- Gitee