1 Star 0 Fork 0

pulin88/mymuduo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Timestamp.cc 694 Bytes
一键复制 编辑 原始数据 按行查看 历史
vmware_centos_pulin 提交于 2022-02-12 01:40 . mymuduo init
#include "Timestamp.h"
#include <time.h>
Timestamp::Timestamp()
{
microSecondSinceEpoch_ = 0;
}
Timestamp::Timestamp(int64_t microSecondSinceEpoch)
{
microSecondSinceEpoch_ = microSecondSinceEpoch;
}
Timestamp Timestamp::now()
{
return Timestamp(time(NULL));
}
std::string Timestamp::toString() const
{
char buf[128] = {0};
tm *tm_time = localtime(&microSecondSinceEpoch_);
snprintf(buf, 128, "%4d/%02d/%02d %02d:%02d:%02d",
tm_time->tm_year + 1900,
tm_time->tm_mon + 1,
tm_time->tm_mday,
tm_time->tm_hour,
tm_time->tm_min,
tm_time->tm_sec);
return buf;
}
/*
int main()
{
cout << Timestamp::now().toString() << endl;
return 0;
}
*/
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/pulin88/mymuduo.git
git@gitee.com:pulin88/mymuduo.git
pulin88
mymuduo
mymuduo
main

搜索帮助