open62541++ 0.13.0
C++ wrapper of open62541
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | List of all members
opcua::DateTime Class Reference

#include <DateTime.h>

Inheritance diagram for opcua::DateTime:
[legend]

Detailed Description

UA_DateTime wrapper class.

An instance in time. A DateTime value is encoded as a 64-bit signed integer which represents the number of 100 nanosecond intervals since January 1, 1601 (UTC).

See also
https://reference.opcfoundation.org/Core/Part6/v105/docs/5.2.2.5
Examples
client_connect.cpp, client_minimal.cpp, client_subscription.cpp, events/client_eventfilter.cpp, and server_valuecallback.cpp.

Definition at line 23 of file DateTime.h.

Public Types

using DefaultClock = std::chrono::system_clock
 
using UaDuration = std::chrono::duration<int64_t, std::ratio<1, 10'000'000>>
 
- Public Types inherited from opcua::Wrapper< T >
using NativeType = T
 

Public Member Functions

template<typename Clock , typename Duration >
 DateTime (std::chrono::time_point< Clock, Duration > timePoint)
 
template<typename Clock = DefaultClock, typename Duration = UaDuration>
std::chrono::time_point< Clock, DurationtoTimePoint () const
 
int64_t toUnixTime () const noexcept
 
UA_DateTimeStruct toStruct () const noexcept
 
int64_t get () const noexcept
 
std::string format (std::string_view format, bool localtime=false) const
 
constexpr TypeWrapper ()=default
 
constexpr TypeWrapper (const T &native)
 
constexpr TypeWrapper (T &&native) noexcept
 
constexpr TypeWrapper (const TypeWrapper &other)
 
constexpr TypeWrapper (TypeWrapper &&other) noexcept
 
- Public Member Functions inherited from opcua::TypeWrapper< UA_DateTime, UA_TYPES_DATETIME >
constexpr TypeWrapper ()=default
 
constexpr TypeWrapper (const UA_DateTime &native)
 
constexpr TypeWrapper (UA_DateTime &&native) noexcept
 
constexpr TypeWrapper (const TypeWrapper &other)
 
constexpr TypeWrapper (TypeWrapper &&other) noexcept
 
 ~TypeWrapper ()
 
constexpr TypeWrapperoperator= (const TypeWrapper &other)
 
constexpr TypeWrapperoperator= (const UA_DateTime &native)
 
constexpr TypeWrapperoperator= (TypeWrapper &&other) noexcept
 
constexpr TypeWrapperoperator= (UA_DateTime &&native) noexcept
 
constexpr void swap (TypeWrapper &other) noexcept
 
constexpr void swap (UA_DateTime &native) noexcept
 
- Public Member Functions inherited from opcua::Wrapper< T >
constexpr Wrapper ()=default
 
constexpr Wrapper (const T &native)
 
constexpr Wrapper (T &&native) noexcept
 
constexpr operator T& () noexcept
 
constexpr operator const T & () const noexcept
 
constexpr T * operator-> () noexcept
 
constexpr const T * operator-> () const noexcept
 
constexpr T * handle () noexcept
 
constexpr const T * handle () const noexcept
 

Static Public Member Functions

static DateTime now () noexcept
 
template<typename Clock , typename Duration >
static DateTime fromTimePoint (std::chrono::time_point< Clock, Duration > timePoint)
 
static DateTime fromUnixTime (int64_t unixTime) noexcept
 
static int64_t localTimeUtcOffset () noexcept
 
- Static Public Member Functions inherited from opcua::TypeWrapper< UA_DateTime, UA_TYPES_DATETIME >
static constexpr TypeIndex getTypeIndex ()
 

Additional Inherited Members

- Protected Member Functions inherited from opcua::TypeWrapper< UA_DateTime, UA_TYPES_DATETIME >
constexpr void clear () noexcept
 
- Protected Member Functions inherited from opcua::Wrapper< T >
constexpr const T & native () const noexcept
 
constexpr T & native () noexcept
 

Member Typedef Documentation

◆ DefaultClock

using opcua::DateTime::DefaultClock = std::chrono::system_clock

Definition at line 25 of file DateTime.h.

◆ UaDuration

using opcua::DateTime::UaDuration = std::chrono::duration<int64_t, std::ratio<1, 10'000'000>>

Definition at line 26 of file DateTime.h.

Constructor & Destructor Documentation

◆ DateTime()

template<typename Clock , typename Duration >
opcua::DateTime::DateTime ( std::chrono::time_point< Clock, Duration > timePoint)
inline

Definition at line 31 of file DateTime.h.

Member Function Documentation

◆ now()

static DateTime opcua::DateTime::now ( )
inlinestaticnoexcept

Get current DateTime.

Examples
events/server_events.cpp, server_datasource.cpp, and server_valuecallback.cpp.

Definition at line 35 of file DateTime.h.

◆ fromTimePoint()

template<typename Clock , typename Duration >
static DateTime opcua::DateTime::fromTimePoint ( std::chrono::time_point< Clock, Duration > timePoint)
inlinestatic

Get DateTime from std::chrono::time_point.

Definition at line 41 of file DateTime.h.

Referenced by opcua::TypeConverter< std::chrono::time_point< Clock, Duration > >::toNative().

◆ fromUnixTime()

static DateTime opcua::DateTime::fromUnixTime ( int64_t unixTime)
inlinestaticnoexcept

Get DateTime from Unix time.

Definition at line 49 of file DateTime.h.

◆ localTimeUtcOffset()

static int64_t opcua::DateTime::localTimeUtcOffset ( )
inlinestaticnoexcept

Offset of local time to UTC.

Definition at line 54 of file DateTime.h.

◆ toTimePoint()

template<typename Clock = DefaultClock, typename Duration = UaDuration>
std::chrono::time_point< Clock, Duration > opcua::DateTime::toTimePoint ( ) const
inline

Convert to std::chrono::time_point.

Definition at line 60 of file DateTime.h.

Referenced by opcua::TypeConverter< std::chrono::time_point< Clock, Duration > >::fromNative().

◆ toUnixTime()

int64_t opcua::DateTime::toUnixTime ( ) const
inlinenoexcept

Convert to Unix time (number of seconds since January 1, 1970 UTC).

Definition at line 70 of file DateTime.h.

◆ toStruct()

UA_DateTimeStruct opcua::DateTime::toStruct ( ) const
inlinenoexcept

Convert to UA_DateTimeStruct.

Definition at line 78 of file DateTime.h.

◆ get()

int64_t opcua::DateTime::get ( ) const
inlinenoexcept

Get DateTime value as 100 nanosecond intervals since January 1, 1601 (UTC).

Definition at line 83 of file DateTime.h.

Referenced by toStruct(), toTimePoint(), and toUnixTime().

◆ format()

std::string opcua::DateTime::format ( std::string_view format,
bool localtime = false ) const

Convert to string with given format (same format codes as strftime).

See also
https://en.cppreference.com/w/cpp/chrono/c/strftime
Examples
client_minimal.cpp, client_subscription.cpp, and server_valuecallback.cpp.

◆ TypeWrapper() [1/5]

constexpr opcua::TypeWrapper< T, typeIndex >::TypeWrapper ( )
constexprdefault

◆ TypeWrapper() [2/5]

constexpr opcua::TypeWrapper< T, typeIndex >::TypeWrapper ( const T & native)
inlineexplicitconstexpr

Constructor with native object (deep copy).

Definition at line 36 of file TypeWrapper.h.

◆ TypeWrapper() [3/5]

constexpr opcua::TypeWrapper< T, typeIndex >::TypeWrapper ( T && native)
inlineconstexprnoexcept

Constructor with native object (move rvalue).

Definition at line 40 of file TypeWrapper.h.

◆ TypeWrapper() [4/5]

constexpr opcua::TypeWrapper< T, typeIndex >::TypeWrapper ( const TypeWrapper & other)
inlineconstexpr

Copy constructor (deep copy).

Definition at line 48 of file TypeWrapper.h.

◆ TypeWrapper() [5/5]

constexpr opcua::TypeWrapper< T, typeIndex >::TypeWrapper ( TypeWrapper && other)
inlineconstexprnoexcept

Move constructor.

Definition at line 52 of file TypeWrapper.h.