POCO库中文编程参考指南(6)Poco::Timestamp
1 类型别名
三个时间戳相关的类型别名,TimeDiff表示两个时间戳的差,第二个是以微秒为单位的时间戳,第三个是以 100 纳秒(0.1 微妙)为单位的时间戳:
typedef Int64 TimeDiff; /// difference between two timestamps in microseconds
typedef Int64 TimeVal; /// monotonic UTC time value in microsecond resolution
typedef Int64 UtcTimeVal; /// monotonic UTC time value in 100 nanosecond resolution
2 构造函数
当前时间的时间戳:
Timestamp();
指定时间的时间戳:
Timestamp(TimeVal tv);
拷贝构造函数:
Timestamp(const Timestamp& other);
3 重载运算符
赋值运算符:
Timestamp& operator = (const Timestamp& other);
Timestamp& operator = (TimeVal tv);
比较运算符:
bool operator == (const Timestamp& ts) const;
bool operator != (const Timestamp& ts) const;
bool operator > (const Timestamp& ts) const;
bool operator >= (const Timestamp& ts) const;
bool operator < (const Timestamp& ts) const;
bool operator <= (const Timestamp& ts) const;
算术运算符与算术赋值运算符
Timestamp operator + (TimeDiff d) const;
Timestamp operator - (TimeDiff d) const;
TimeDiff operator - (const Timestamp& ts) const;
Timestamp& operator += (TimeDiff d);
Timestamp& operator -= (TimeDiff d);
4 获取不同格式表示的时间戳
获取 std::time_t 格式的时间戳:
std::time_t epochTime() const;
获取 UTC-based time 格式的时间戳:
UtcTimeVal utcTime() const;
获取 TimeVal 格式(微秒)的时间戳:
TimeVal epochMicroseconds() const;
5 其他成员函数
交换时间戳:
void swap(Timestamp& timestamp);
更新时间戳为当前时间:
void update();
此时时间戳与这个时间戳的差(TimeStamp() - *this):
TimeDiff elapsed() const;
判断一段时间是否已经过去:
bool isElapsed(TimeDiff interval) const;
6 静态成员函数
用std::time_t对象创建一个Timestamp:
static Timestamp fromEpochTime(std::time_t t);
用UtcTimeVal对象创建一个Timestamp:
static Timestamp fromUtcTime(UtcTimeVal val);
返回时间解析度,即 Units per second。因为 Poco::TimeStamp 的最小解析度为微妙,所以该函数都返回 1000000:
static TimeVal resolution();
-
POCO库中文编程参考指南(6)Poco::Timestamp的更多相关文章
- POCO库中文编程参考指南(4)Poco::Net::IPAddress
POCO库中文编程参考指南(4)Poco::Net::IPAddress 作者:柳大·Poechant 博客:Blog.CSDN.net/Poechant 邮箱:zhongchao.ustc#gmai ...
- POCO库中文编程参考指南(3)Poco::Net::Socket
POCO库中文编程参考指南(3)Poco::Net::Socket 作者:柳大·Poechant 博客:Blog.CSDN.net/Poechant 邮箱:zhongchao.ustc#gmail.c ...
- POCO库中文编程参考指南(2)基本数据类型(Poco/Types.h)
POCO库中文编程参考指南(2)基本数据类型 作者:柳大·Poechant 博客:Blog.CSDN.net/Poechant 邮箱:zhongchao.ustc#gmail.com (# -> ...
- POCO库中文编程参考指南(1)总览
POCO库中文编程参考指南(1)总览 作者:柳大·Poechant 博客:Blog.CSDN.net/Poechant 邮箱:zhongchao.ustc#gmail.com (# -> @) ...
- POCO库中文编程参考指南(11)如何使用Reactor框架?
1 Reactor 框架概述 POCO 中的 Reactor 框架是基于 Reactor 设计模式进行设计的.其中由 Handler 将某 Socket 产生的事件,发送到指定的对象的方法上,作为回调 ...
- POCO库中文编程参考指南(8)丰富的Socket编程
POCO库中文编程参考指南(8)丰富的Socket编程 作者:柳大·Poechant 博客:Blog.CSDN.net/Poechant 邮箱:zhongchao.ustc#gmail.com (# ...
- POCO库中文编程参考指南(10)如何使用TCPServer框架?
1 TCPServer 框架概述 POCO 库提供TCPServer框架,用以搭建自定义的 TCP 服务器.TCPServer维护一个连接队列.一个连接线程池.连接线程用于处理连接,连接线程只要一空闲 ...
- POCO库中文编程参考指南(9)Poco::Net::DNS
1 Poco::Net::DNS namespace Poco { namespace Net { class Net_API DNS { public: static HostEntry hostB ...
- POCO库中文编程参考指南(5)Poco::Net::SocketAddress
1 枚举 最大地址长度,这个与Poco::Net::IPAddress中的定义可以类比,不过这里指的是`struct sockaddr_in6 enum { MAX_ADDRESS_LENGTH = ...
随机推荐
- 18式优雅你的Python
本文来自读者梁云同学的投稿,公众号:Python与算法之美 一,优雅你的Jupyter 1,更改Jupyter Notebook初始工作路径 平凡方法: 在cmd中输入jupyter notebook ...
- perl语言入门总结-第3章-列表与数组
1-列表list指的是标题的有序集合, 而数组(array)则是存储列表的变量. 更精确地说,列表指的是数据,而数组指的是变量. 访问数组中的元素 ] = "yabba"; ] = ...
- vim基本配置备份
我的vim基本配置如下,在这里作个备份: set background=light syntax on set number set smartindent set expandtab set tab ...
- selenium定位弹出菜单
写selenium脚本,在浏览器定位各种弹出菜单时,有时用工具很难去取菜单的属性,下面说下如何去取: 点开firebug ,切换到“脚本”界面,首先在输入框输入单字母s,待弹出下拉列表后,单击左侧的插 ...
- CS/BS架构的特点
CS架构 优点: 1.有独立的客户端,安全性高 2.大部分业务都在客户端实现,可以实现很复杂的业务 缺点: 1.对环境要求高,需要安装客户端,推广速度慢 2.需要专门前后台的开发团队,维护成本高 B/ ...
- selenium获取浏览器控制台日志
public void logsTest(){ WebDriver driver = null; try { System.setProperty("webdriver.chrome.dri ...
- 4.实现简单的shell sed替换功能
# -*- coding:utf-8 -*- # Author: JACK ZHAO # 程序1: 实现简单的shell sed替换功能 import sys #判断参数个数 if len(sys.a ...
- 安装启动Apache2.4后报Invalid command 'Order', perhaps misspelled or defined by a module not included in the server configuration错误
LoadModule access_compat_module modules/mod_access_compat.so 取消这一行模块的注释,再重启服务即可. 搜索 mod_access_compa ...
- Python全栈 MySQL 数据库 (索引、数据导入、导出)
ParisGabriel 每天坚持手写 一天一篇 决定坚持几年 为了梦想为了信仰 开局一张图 表字段重命名(change) alter table 表名 ...
- Mybatis + Oracle 批量insert的问题
这个问题真的太坑了 之前用ibatis+sql server 的foreach 很容易就写出来批量insert数据,但是测试后报错:SQL结束格式错误 现在换到银行工作,数据库也换成Oracle了 特 ...