C++ Utilities 5.24.7
Useful C++ classes and routines such as argument parser, IO and conversion utilities
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
CppUtilities::DateTimeExpression Struct Reference

The DateTimeExpression struct holds information about a time expression (e.g. More...

#include <datetime.h>

Collaboration diagram for CppUtilities::DateTimeExpression:
[legend]

Public Member Functions

constexpr DateTime gmt () const
 Returns the value in UTC time.
 
constexpr bool operator== (const DateTimeExpression &other) const
 Returns whether the expressions are equivalent.
 
std::string toIsoString (char dateDelimiter='-', char timeDelimiter=':', char timeZoneDelimiter=':') const
 Returns the string representation of the current instance in the ISO format.
 

Static Public Member Functions

static DateTimeExpression fromIsoString (const char *str)
 Parses the specified ISO date time denotation provided as C-style string.
 
static DateTimeExpression fromString (const char *str)
 Parses the given C-style string.
 

Public Attributes

DateTime value
 
TimeSpan delta
 
DateTimeParts parts = DateTimeParts::None
 

Detailed Description

The DateTimeExpression struct holds information about a time expression (e.g.

an ISO-8601 timestamp).

This struct holds the date and time specification (DateTimeExpression::value), the time-zone delta (DateTimeExpression::delta) and what parts are actually specified (DateTimeExpression::parts).

The idea is to be able to preserve a time-zone delta and present parts when deserializing and then serializing again. Note that it still does not allow to preserve the format of the original timestamp exactly.

Definition at line 163 of file datetime.h.

Member Function Documentation

◆ fromIsoString()

DateTimeExpression CppUtilities::DateTimeExpression::fromIsoString ( const char * str)
static

Parses the specified ISO date time denotation provided as C-style string.

Exceptions
Throwsa ConversionException if the specified str does not match the expected time format.
Remarks
  • Parsing durations and time intervals is not supported.
  • Truncated representations are not supported.
  • Standardised extensions (ISO 8601-2:2019) are not supported.
See also
https://en.wikipedia.org/wiki/ISO_8601

Definition at line 388 of file datetime.cpp.

◆ fromString()

DateTimeExpression CppUtilities::DateTimeExpression::fromString ( const char * str)
static

Parses the given C-style string.

Exceptions
Throwsa ConversionException if the specified str does not match the expected time format.

The expected format is something like "2012-02-29 15:34:20.033" or "2012/02/29 15:34:20.033". The delimiters '-', ':' and '/' are exchangeable.

See also
DateTimeExpression::fromIsoString()

Definition at line 488 of file datetime.cpp.

◆ gmt()

constexpr DateTime CppUtilities::DateTimeExpression::gmt ( ) const
constexpr

Returns the value in UTC time.

Definition at line 178 of file datetime.h.

◆ operator==()

constexpr bool CppUtilities::DateTimeExpression::operator== ( const DateTimeExpression & other) const
constexpr

Returns whether the expressions are equivalent.

Definition at line 186 of file datetime.h.

◆ toIsoString()

std::string CppUtilities::DateTimeExpression::toIsoString ( char dateDelimiter = '-',
char timeDelimiter = ':',
char timeZoneDelimiter = ':' ) const

Returns the string representation of the current instance in the ISO format.

Remarks
Only present parts will be included.

Definition at line 533 of file datetime.cpp.

Member Data Documentation

◆ delta

TimeSpan CppUtilities::DateTimeExpression::delta

The delta of value from UTC as TimeSpan object.

Definition at line 165 of file datetime.h.

◆ parts

DateTimeParts CppUtilities::DateTimeExpression::parts = DateTimeParts::None

The parts present in the expression as flag enum.

Definition at line 166 of file datetime.h.

◆ value

DateTime CppUtilities::DateTimeExpression::value

The value of the time expression as DateTime object.

Definition at line 164 of file datetime.h.


The documentation for this struct was generated from the following files: