| Disk ARchive 2.8.3 Full featured and portable backup and archiving tool

Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
libdar::datetime Class Reference
API

stores time information More...

`#include <datetime.hpp>`

## Public Types
enum | time_unit { tu_nanosecond , tu_microsecond , tu_second , tu_nanosecond , tu_microsecond , tu_second }
enum | time_unit { tu_nanosecond , tu_microsecond , tu_second , tu_nanosecond , tu_microsecond , tu_second }

## Public Member Functions
| datetime (const infinint &value=0)
| constructor based on the number of second ellasped since the end of 1969
| datetime (time_t second, time_t subsec, time_unit unit)
| general constructor
| datetime (generic_file &x, archive_version ver)
| constructor reading data dump() into a generic_file
| datetime (const datetime &ref)=default
| datetime (datetime &&ref) noexcept=default
datetime & | operator= (const datetime &ref)=default
datetime & | operator= (datetime &&ref) noexcept=default
bool | operator< (const datetime &ref) const
bool | operator== (const datetime &ref) const
bool | operator!= (const datetime &ref) const
bool | operator>= (const datetime &ref) const
bool | operator> (const datetime &ref) const
bool | operator<= (const datetime &ref) const
void | operator-= (const datetime &ref)
void | operator+= (const datetime &ref)
datetime | operator- (const datetime &ref) const
datetime | operator+ (const datetime &ref) const
bool | loose_equal (const datetime &ref) const
| equivalent to operator == but if compared object use different time unit, do the comparison rounding up the values to the largest unit
datetime | loose_diff (const datetime &ref) const
| at the difference of operator - provides the difference using the less precise unit used between the two elements
infinint | get_second_value () const
| return the integer number of second
infinint | get_subsecond_value (time_unit unit) const
| return the subsecond time fraction expressed in the given time unit
time_unit | get_unit () const
| returns the time unit used internally to store the subsecond time fraction
bool | get_value (time_t &second, time_t &subsecond, time_unit unit) const
| return a time as time_t arguments
void | dump (generic_file &x) const
| write down this to file
void | read (generic_file &f, archive_version ver)
| read this from file
bool | is_null () const
| return true if the datetime is exactly January 1st, 1970, 0 h 0 mn 0 s
bool | is_integer_second () const
| return true if the datetime is an integer number of second (subsecond part is zero)
infinint | get_storage_size () const
| return the storage it would require to dump this object
void | nullify ()
| set to null (zero)
| datetime (const infinint &value=0)
| constructor based on the number of second ellasped since the end of 1969
| datetime (time_t second, time_t subsec, time_unit unit)
| general constructor
| datetime (generic_file &x, archive_version ver)
| constructor reading data dump() into a generic_file
| datetime (const datetime &ref)=default
| datetime (datetime &&ref) noexcept=default
datetime & | operator= (const datetime &ref)=default
datetime & | operator= (datetime &&ref) noexcept=default
bool | operator< (const datetime &ref) const
bool | operator== (const datetime &ref) const
bool | operator!= (const datetime &ref) const
bool | operator>= (const datetime &ref) const
bool | operator> (const datetime &ref) const
bool | operator<= (const datetime &ref) const
void | operator-= (const datetime &ref)
void | operator+= (const datetime &ref)
datetime | operator- (const datetime &ref) const
datetime | operator+ (const datetime &ref) const
bool | loose_equal (const datetime &ref) const
| equivalent to operator == but if compared object use different time unit, do the comparison rounding up the values to the largest unit
datetime | loose_diff (const datetime &ref) const
| at the difference of operator - provides the difference using the less precise unit used between the two elements
infinint | get_second_value () const
| return the integer number of second
infinint | get_subsecond_value (time_unit unit) const
| return the subsecond time fraction expressed in the given time unit
time_unit | get_unit () const
| returns the time unit used internally to store the subsecond time fraction
bool | get_value (time_t &second, time_t &subsecond, time_unit unit) const
| return a time as time_t arguments
void | dump (generic_file &x) const
| write down this to file
void | read (generic_file &f, archive_version ver)
| read this from file
bool | is_null () const
| return true if the datetime is exactly January 1st, 1970, 0 h 0 mn 0 s
bool | is_integer_second () const
| return true if the datetime is an integer number of second (subsecond part is zero)
infinint | get_storage_size () const
| return the storage it would require to dump this object
void | nullify ()
| set to null (zero)

## Static Public Member Functions
static std::string | unit_symbol (time_unit tu)
| return the SI symbol of the time unit (s, ms, us (should be mu greek letter), ns)
static std::string | unit_symbol (time_unit tu)
| return the SI symbol of the time unit (s, ms, us (should be mu greek letter), ns)

## Private Member Functions
void | reduce_to_largest_unit () const
| reduce the value to the largest unit possible
void | get_value (infinint &sec, infinint &sub, time_unit unit) const
void | build (const infinint &sec, const infinint &sub, time_unit unit)
void | reduce_to_largest_unit () const
| reduce the value to the largest unit possible
void | get_value (infinint &sec, infinint &sub, time_unit unit) const
void | build (const infinint &sec, const infinint &sub, time_unit unit)

## Static Private Member Functions
static time_unit | min (time_unit a, time_unit b)
static time_unit | max (time_unit a, time_unit b)
static char | time_unit_to_char (time_unit a)
static time_unit | char_to_time_unit (const char a)
static const infinint & | get_scaling_factor (time_unit source, time_unit dest)
| return the factor between two units
static time_unit | min (time_unit a, time_unit b)
static time_unit | max (time_unit a, time_unit b)
static char | time_unit_to_char (time_unit a)
static time_unit | char_to_time_unit (const char a)
static const infinint & | get_scaling_factor (time_unit source, time_unit dest)
| return the factor between two units

## Private Attributes
infinint | val
| the date expressed in the "uni" time unit
time_unit | uni
| the time unit used to store the subsecond fraction of the timestamp.

## Detailed Description

stores time information

Definition at line 58 of file dar64-2.8.3-win64/include/dar/datetime.hpp.

## Member Enumeration Documentation

## ◆ time_unit [1/2]

enum libdar::datetime::time_unit

Definition at line 63 of file dar64-2.8.3-win64/include/dar/datetime.hpp.

## ◆ time_unit [2/2]

enum libdar::datetime::time_unit

Definition at line 63 of file src/libdar/datetime.hpp.

## Constructor & Destructor Documentation

## ◆ datetime() [1/4]

libdar::datetime::datetime | ( | const infinint & | value = 0 | ) |
| inline

constructor based on the number of second ellasped since the end of 1969

Definition at line 66 of file dar64-2.8.3-win64/include/dar/datetime.hpp.

References uni, and val.

Referenced by datetime(), loose_diff(), and loose_equal().

## ◆ datetime() [2/4]

libdar::datetime::datetime | ( | time_t | second,
|  | time_t | subsec,
|  | time_unit | unit )

general constructor

Parameters

  [in] | second | the number of second since the dawn of computer time (1970)
  [in] | subsec | the fraction of the time below 1 second expressed in the time unit given as next argument
  [in] | unit | the time unit in which is expressed the previous argument

## ◆ datetime() [3/4]

libdar::datetime::datetime | ( | const infinint & | value = 0 | ) |
| inline

constructor based on the number of second ellasped since the end of 1969

Definition at line 66 of file src/libdar/datetime.hpp.

References uni, and val.

## ◆ datetime() [4/4]

libdar::datetime::datetime | ( | time_t | second,
|  | time_t | subsec,
|  | time_unit | unit )

general constructor

Parameters

  [in] | second | the number of second since the dawn of computer time (1970)
  [in] | subsec | the fraction of the time below 1 second expressed in the time unit given as next argument
  [in] | unit | the time unit in which is expressed the previous argument

## Member Function Documentation

## ◆ get_scaling_factor() [1/2]

const infinint & libdar::datetime::get_scaling_factor | ( | time_unit | source,
|  | time_unit | dest )
| static private

return the factor between two units

Note
  "source" must be larger than "dest" (source >= dest), else an exception is thrown

Returns
  the factor f, which makes the following to be true: source = f*dest

## ◆ get_scaling_factor() [2/2]

const infinint & libdar::datetime::get_scaling_factor | ( | time_unit | source,
|  | time_unit | dest )
| static private

return the factor between two units

Note
  "source" must be larger than "dest" (source >= dest), else an exception is thrown

Returns
  the factor f, which makes the following to be true: source = f*dest

## ◆ get_second_value() [1/2]

infinint libdar::datetime::get_second_value | ( |  | ) | const
| inline

return the integer number of second

Definition at line 107 of file dar64-2.8.3-win64/include/dar/datetime.hpp.

References get_value(), and uni.

## ◆ get_second_value() [2/2]

infinint libdar::datetime::get_second_value | ( |  | ) | const
| inline

return the integer number of second

Definition at line 107 of file src/libdar/datetime.hpp.

References get_value(), and uni.

## ◆ get_unit() [1/2]

time_unit libdar::datetime::get_unit | ( |  | ) | const
| inline

returns the time unit used internally to store the subsecond time fraction

Definition at line 113 of file dar64-2.8.3-win64/include/dar/datetime.hpp.

References uni.

## ◆ get_unit() [2/2]

time_unit libdar::datetime::get_unit | ( |  | ) | const
| inline

returns the time unit used internally to store the subsecond time fraction

Definition at line 113 of file src/libdar/datetime.hpp.

References uni.

## ◆ get_value() [1/2]

bool libdar::datetime::get_value | ( | time_t & | second,
|  | time_t & | subsecond,
|  | time_unit | unit ) const

return a time as time_t arguments

Parameters

  [out] | second | the time value in second
  [out] | subsecond | is the remaining time fraction as expressed in the unit given as next argument
  [in] | unit | the unit of the subsecond fraction of the timestamp

Returns
  true upon success, false if the value cannot be represented by system types (overflow)

Referenced by get_second_value().

## ◆ get_value() [2/2]

bool libdar::datetime::get_value | ( | time_t & | second,
|  | time_t & | subsecond,
|  | time_unit | unit ) const

return a time as time_t arguments

Parameters

  [out] | second | the time value in second
  [out] | subsecond | is the remaining time fraction as expressed in the unit given as next argument
  [in] | unit | the unit of the subsecond fraction of the timestamp

Returns
  true upon success, false if the value cannot be represented by system types (overflow)

## ◆ is_integer_second() [1/2]

bool libdar::datetime::is_integer_second | ( |  | ) | const
| inline

return true if the datetime is an integer number of second (subsecond part is zero)

Definition at line 134 of file dar64-2.8.3-win64/include/dar/datetime.hpp.

References uni.

## ◆ is_integer_second() [2/2]

bool libdar::datetime::is_integer_second | ( |  | ) | const
| inline

return true if the datetime is an integer number of second (subsecond part is zero)

Definition at line 134 of file src/libdar/datetime.hpp.

References uni.

## ◆ is_null() [1/2]

bool libdar::datetime::is_null | ( |  | ) | const
| inline

return true if the datetime is exactly January 1st, 1970, 0 h 0 mn 0 s

Definition at line 131 of file dar64-2.8.3-win64/include/dar/datetime.hpp.

References val.

## ◆ is_null() [2/2]

bool libdar::datetime::is_null | ( |  | ) | const
| inline

return true if the datetime is exactly January 1st, 1970, 0 h 0 mn 0 s

Definition at line 131 of file src/libdar/datetime.hpp.

References val.

## ◆ nullify() [1/2]

void libdar::datetime::nullify | ( |  | ) |
| inline

set to null (zero)

Definition at line 140 of file dar64-2.8.3-win64/include/dar/datetime.hpp.

References uni, and val.

## ◆ nullify() [2/2]

void libdar::datetime::nullify | ( |  | ) |
| inline

set to null (zero)

Definition at line 140 of file src/libdar/datetime.hpp.

References uni, and val.

## ◆ operator!=() [1/2]

bool libdar::datetime::operator!= | ( | const datetime & | ref | ) | const
| inline

Definition at line 89 of file dar64-2.8.3-win64/include/dar/datetime.hpp.

## ◆ operator!=() [2/2]

bool libdar::datetime::operator!= | ( | const datetime & | ref | ) | const
| inline

Definition at line 89 of file src/libdar/datetime.hpp.

## ◆ operator+() [1/2]

datetime libdar::datetime::operator+ | ( | const datetime & | ref | ) | const
| inline

Definition at line 98 of file dar64-2.8.3-win64/include/dar/datetime.hpp.

## ◆ operator+() [2/2]

datetime libdar::datetime::operator+ | ( | const datetime & | ref | ) | const
| inline

Definition at line 98 of file src/libdar/datetime.hpp.

## ◆ operator-() [1/2]

datetime libdar::datetime::operator- | ( | const datetime & | ref | ) | const
| inline

Definition at line 97 of file dar64-2.8.3-win64/include/dar/datetime.hpp.

## ◆ operator-() [2/2]

datetime libdar::datetime::operator- | ( | const datetime & | ref | ) | const
| inline

Definition at line 97 of file src/libdar/datetime.hpp.

## ◆ operator<=() [1/2]

bool libdar::datetime::operator<= | ( | const datetime & | ref | ) | const
| inline

Definition at line 92 of file dar64-2.8.3-win64/include/dar/datetime.hpp.

## ◆ operator<=() [2/2]

bool libdar::datetime::operator<= | ( | const datetime & | ref | ) | const
| inline

Definition at line 92 of file src/libdar/datetime.hpp.

## ◆ operator>() [1/2]

bool libdar::datetime::operator> | ( | const datetime & | ref | ) | const
| inline

Definition at line 91 of file dar64-2.8.3-win64/include/dar/datetime.hpp.

## ◆ operator>() [2/2]

bool libdar::datetime::operator> | ( | const datetime & | ref | ) | const
| inline

Definition at line 91 of file src/libdar/datetime.hpp.

## ◆ operator>=() [1/2]

bool libdar::datetime::operator>= | ( | const datetime & | ref | ) | const
| inline

Definition at line 90 of file dar64-2.8.3-win64/include/dar/datetime.hpp.

## ◆ operator>=() [2/2]

bool libdar::datetime::operator>= | ( | const datetime & | ref | ) | const
| inline

Definition at line 90 of file src/libdar/datetime.hpp.

## Member Data Documentation

## ◆ uni

time_unit libdar::datetime::uni
| private

the time unit used to store the subsecond fraction of the timestamp.

Definition at line 153 of file dar64-2.8.3-win64/include/dar/datetime.hpp.

Referenced by datetime(), get_second_value(), get_unit(), is_integer_second(), nullify(), and unit_symbol().

## ◆ val

infinint libdar::datetime::val
| private

the date expressed in the "uni" time unit

Definition at line 152 of file dar64-2.8.3-win64/include/dar/datetime.hpp.

Referenced by datetime(), is_null(), nullify(), and unit_symbol().

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

- dar64-2.8.3-win64/include/dar/datetime.hpp
- src/libdar/datetime.hpp