This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
tango-certstore/src/rt/rt_time.c
fengweihao a9b9607408 [添加文件]
1.添加CertStore源代码程序文件
[目录层次介绍]
1.conf为配置文件
2.make为Makefile配置文件
3.release为执行make tarball后生成的安装包文件
4.src源代码
src/components 使用的静态库所需的头文件(libevent、openssl、hiredis)
src/inc        系统所需头文件
src/lib        静态库
src/package    安装包临时目录
src/rt         功能函数代码
[编译运行]
1.cd src && make
2../cert_store --debug[release/deamon]
[安装包使用]
1.cd src && make tarball
2.cd release (获取安装包)
2.1.tar -zxvf xxxx.tar.gz
2.2 cd xxx.tar.gz && make install
[版本问题]
1.证书生成代码屏蔽(未调通)
2.Redis超时处理未完成
3.连接响应断开后,资源未释放
2018-06-19 11:32:16 +08:00

59 lines
1.2 KiB
C

/*
* rt_time.c
* Created by fengweihao
* 30 May, 2018
* Func: Time Component
*/
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <time.h>
#include <assert.h>
#include <errno.h>
#include "rt_time.h"
struct tm *rt_localtime(time_t timep, struct tm *result)
{
return localtime_r(&timep, result);
}
uint64_t rt_time_s(void)
{
struct timeval tv;
gettimeofday(&tv, NULL);
return (tv.tv_sec + tv.tv_usec/1000/1000); /** CST timestamp */
};
uint64_t rt_time_ms(void)
{
struct timeval tv;
gettimeofday(&tv, NULL);
return (tv.tv_sec * 1000 + tv.tv_usec/1000);
}
uint64_t rt_time_ns()
{
struct timeval tv;
gettimeofday(&tv, NULL);
return (tv.tv_sec * 1000 * 1000 + tv.tv_usec);
}
int rt_tms2str(uint64_t ts, const char *tm_form, char *date, size_t len)
{
struct tm *tm = NULL;
assert(date);
/** Convert ts to localtime with local time-zone */
tm = localtime((time_t *)&ts);
return (int)strftime(date, len - 1, tm_form, tm);
}
int rt_curr_tms2str(const char *tm_form, char *date, size_t len)
{
return rt_tms2str(time(NULL), tm_form, date, len);
}