NexusForce 1.0.0
A Modern C++ Library with extended functionality, web components, and utility libraries
载入中...
搜索中...
未找到
timestamp类 参考

时间戳类 更多...

#include <datetime.hpp>

类 timestamp 继承关系图:
[图例]

Public 类型

using value_type = int64_t
 值类型
Public 类型 继承自 ipackage< timestamp, int64_t >
using package_type
 包装类型

Public 成员函数

constexpr timestamp (const value_type value) noexcept
 从秒数构造
constexpr timestamp (const datetime &dt) noexcept
 从日期时间构造
NEFORCE_NODISCARD constexpr datetime to_datetime () const noexcept
 转换为日期时间
NEFORCE_NODISCARD NEFORCE_CONSTEXPR20 string to_string () const
 转换为字符串
constexpr void clear () noexcept
 重置为0
Public 成员函数 继承自 iobject< timestamp >
NEFORCE_CONSTEXPR20 bool try_parse (const string_view str) noexcept
 尝试从字符串解析对象
Public 成员函数 继承自 istringify< timestamp >
NEFORCE_NODISCARD NEFORCE_CONSTEXPR20 string to_string () const
 转换为字符串
Public 成员函数 继承自 ipackage< timestamp, int64_t >
NEFORCE_NODISCARD constexpr operator package_type () const noexcept
 类型转换操作符
NEFORCE_NODISCARD constexpr package_type value () const noexcept
 获取数值
NEFORCE_NODISCARD constexpr int64_t to_int64 () const noexcept
 转换为64位整数
NEFORCE_NODISCARD constexpr size_t to_hash () const noexcept
 计算哈希值
constexpr void swap (timestamp &other) noexcept
 交换内容
NEFORCE_NODISCARD constexpr bool operator== (const timestamp &other) const noexcept
 相等比较操作符
NEFORCE_NODISCARD constexpr bool operator< (const timestamp &other) const noexcept
 小于比较操作符
constexpr timestampoperator+= (const timestamp &other) noexcept
 加法赋值操作符
constexpr timestampoperator-= (const timestamp &other) noexcept
 减法赋值操作符
constexpr timestampoperator*= (const timestamp &other) noexcept
 乘法赋值操作符
constexpr timestampoperator/= (const timestamp &other)
 除法赋值操作符
constexpr timestampoperator%= (const timestamp &other)
 取模赋值操作符
NEFORCE_NODISCARD constexpr timestamp operator- () const noexcept
 一元负号操作符
constexpr timestampoperator++ () noexcept
 前置递增操作符
constexpr timestampoperator-- () noexcept
 前置递减操作符
constexpr timestamp operator~ () const noexcept
 按位取反操作符
constexpr timestampoperator&= (const timestamp &other) noexcept
 按位与赋值操作符
constexpr timestampoperator|= (const timestamp &other) noexcept
 按位或赋值操作符
constexpr timestampoperator^= (const timestamp &other) noexcept
 按位异或赋值操作符
constexpr timestampoperator<<= (const uint32_t shift)
 左移赋值操作符
constexpr timestampoperator>>= (const uint32_t shift)
 右移赋值操作符
Public 成员函数 继承自 icomparable< timestamp >
NEFORCE_NODISCARD constexpr bool operator== (const timestamp &rhs) const noexcept(noexcept(derived()==rhs))
 相等比较运算符
NEFORCE_NODISCARD constexpr bool operator!= (const timestamp &rhs) const noexcept(noexcept(!(*this==rhs)))
 不等比较运算符
NEFORCE_NODISCARD constexpr bool operator< (const timestamp &rhs) const noexcept(noexcept(derived()< rhs))
 小于比较运算符
NEFORCE_NODISCARD constexpr bool operator> (const timestamp &rhs) const noexcept(noexcept(rhs< derived()))
 大于比较运算符
NEFORCE_NODISCARD constexpr bool operator<= (const timestamp &rhs) const noexcept(noexcept(!(derived() > rhs)))
 小于等于比较运算符
NEFORCE_NODISCARD constexpr bool operator>= (const timestamp &rhs) const noexcept(noexcept(!(derived()< rhs)))
 大于等于比较运算符
Public 成员函数 继承自 ihashable< timestamp >
NEFORCE_NODISCARD constexpr size_t to_hash () const noexcept(noexcept(derived().to_hash()))
 获取对象的哈希值
Public 成员函数 继承自 iarithmetic< timestamp >
NEFORCE_NODISCARD NEFORCE_CONSTEXPR14 timestamp operator+ (const timestamp &other) const noexcept(noexcept(const_cast< timestamp & >(derived()).operator+=(other)))
 加法运算符
NEFORCE_NODISCARD NEFORCE_CONSTEXPR14 timestamp operator- (const timestamp &other) const noexcept(noexcept(const_cast< timestamp & >(derived()).operator-=(other)))
 减法运算符
NEFORCE_NODISCARD NEFORCE_CONSTEXPR14 timestamp operator* (const timestamp &other) const noexcept(noexcept(const_cast< timestamp & >(derived()).operator*=(other)))
 乘法运算符
NEFORCE_NODISCARD NEFORCE_CONSTEXPR14 timestamp operator/ (const timestamp &other) const noexcept(noexcept(const_cast< timestamp & >(derived()).operator/=(other)))
 除法运算符
NEFORCE_NODISCARD NEFORCE_CONSTEXPR14 timestamp operator% (const timestamp &other) const noexcept(noexcept(const_cast< timestamp & >(derived()).operator%=(other)))
 取模运算符
NEFORCE_CONSTEXPR14 timestampoperator+= (const timestamp &other) noexcept(noexcept(derived().operator+=(other)))
 加法赋值运算符
NEFORCE_CONSTEXPR14 timestampoperator-= (const timestamp &other) noexcept(noexcept(derived().operator-=(other)))
 减法赋值运算符
NEFORCE_CONSTEXPR14 timestampoperator*= (const timestamp &other) noexcept(noexcept(derived().operator*=(other)))
 乘法赋值运算符
NEFORCE_CONSTEXPR14 timestampoperator/= (const timestamp &other)
 除法赋值运算符
NEFORCE_CONSTEXPR14 timestampoperator%= (const timestamp &other)
 取模赋值运算符
NEFORCE_CONSTEXPR14 timestampoperator++ () noexcept(noexcept(derived().operator++()))
 前置自增运算符
NEFORCE_CONSTEXPR14 timestampoperator-- () noexcept(noexcept(derived().operator--()))
 前置自减运算符
Public 成员函数 继承自 ibinary< timestamp >
NEFORCE_NODISCARD NEFORCE_CONSTEXPR14 timestamp operator& (const timestamp &other) const noexcept(noexcept(const_cast< timestamp & >(derived()).operator&=(other)))
 按位与运算符
NEFORCE_NODISCARD NEFORCE_CONSTEXPR14 timestamp operator| (const timestamp &other) const noexcept(noexcept(const_cast< timestamp & >(derived()).operator|=(other)))
 按位或运算符
NEFORCE_NODISCARD NEFORCE_CONSTEXPR14 timestamp operator^ (const timestamp &other) const noexcept(noexcept(const_cast< timestamp & >(derived()).operator^=(other)))
 按位异或运算符
NEFORCE_NODISCARD NEFORCE_CONSTEXPR14 timestamp operator~ () const noexcept(noexcept(derived().operator~()))
 按位取反运算符
NEFORCE_NODISCARD NEFORCE_CONSTEXPR14 timestamp operator<< (const uint32_t shift) const
 左移运算符
NEFORCE_NODISCARD NEFORCE_CONSTEXPR14 timestamp operator>> (const uint32_t shift) const
 右移运算符
NEFORCE_CONSTEXPR14 timestampoperator&= (const timestamp &other) noexcept(noexcept(derived().operator&=(other)))
 按位与赋值运算符
NEFORCE_CONSTEXPR14 timestampoperator|= (const timestamp &other) noexcept(noexcept(derived().operator|=(other)))
 按位或赋值运算符
NEFORCE_CONSTEXPR14 timestampoperator^= (const timestamp &other) noexcept(noexcept(derived().operator^=(other)))
 按位异或赋值运算符
NEFORCE_CONSTEXPR14 timestampoperator<<= (const uint32_t shift)
 左移赋值运算符
NEFORCE_CONSTEXPR14 timestampoperator>>= (const uint32_t shift)
 右移赋值运算符

静态 Public 成员函数

static NEFORCE_NODISCARD timestamp now () noexcept
 获取当前时间戳
static NEFORCE_NODISCARD constexpr timestamp parse (const string_view view)
 从字符串解析
静态 Public 成员函数 继承自 iobject< timestamp >
static NEFORCE_NODISCARD constexpr timestamp parse (const string_view str)
 从字符串解析对象
静态 Public 成员函数 继承自 ipackage< timestamp, int64_t >
static NEFORCE_NODISCARD constexpr size_t bytes () noexcept
 获取类型字节大小
static NEFORCE_NODISCARD constexpr size_t bits () noexcept
 获取类型位大小

额外继承的成员函数

Protected 成员函数 继承自 ipackage< timestamp, int64_t >
NEFORCE_CONSTEXPR20 ~ipackage ()=default
 受保护的析构函数
Protected 属性 继承自 ipackage< timestamp, int64_t >
package_type value_
 存储的数值

详细描述

时间戳类

表示从1970-01-01 00:00:00 UTC开始的秒数。 包装了int64_t,提供与datetime的相互转换。

在文件 datetime.hpp1453 行定义.

构造及析构函数说明

◆ timestamp() [1/2]

timestamp::timestamp ( const value_type value)
inlineexplicitconstexprnoexcept

从秒数构造

参数
value秒数

在文件 datetime.hpp1484 行定义.

引用了 ipackage< timestamp, int64_t >::value().

◆ timestamp() [2/2]

timestamp::timestamp ( const datetime & dt)
inlineexplicitconstexprnoexcept

从日期时间构造

参数
dt日期时间

在文件 datetime.hpp1491 行定义.

引用了 datetime::epoch(), datetime::to_UTC() , 以及 ipackage< timestamp, int64_t >::value_.

成员函数说明

◆ now()

NEFORCE_NODISCARD timestamp timestamp::now ( )
inlinestaticnoexcept

获取当前时间戳

返回
当前时间戳

在文件 datetime.hpp1500 行定义.

引用了 datetime::now().

被这些函数引用 get_current_task_group().

◆ parse()

NEFORCE_NODISCARD constexpr timestamp timestamp::parse ( const string_view view)
inlinestaticconstexpr

从字符串解析

参数
view数字字符串
返回
解析得到的时间戳

在文件 datetime.hpp1519 行定义.

◆ to_datetime()

NEFORCE_NODISCARD constexpr datetime timestamp::to_datetime ( ) const
inlineconstexprnoexcept

转换为日期时间

返回
对应的日期时间

在文件 datetime.hpp1506 行定义.

引用了 datetime::epoch() , 以及 ipackage< timestamp, int64_t >::value_.

◆ to_string()

NEFORCE_NODISCARD NEFORCE_CONSTEXPR20 string timestamp::to_string ( ) const
inline

转换为字符串

返回
数字字符串

在文件 datetime.hpp1512 行定义.

引用了 ipackage< timestamp, int64_t >::value_.


该类的文档由以下文件生成: