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

Public Types | 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 }

## 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 More...
| 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 More...
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)

## 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)

## 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 const 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 More...

## Private Attributes
infinint | val
time_unit | uni

## Detailed Description

stores time information

Definition at line 58 of file datetime.hpp.

## Constructor & Destructor Documentation

## ◆ datetime()

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()

static 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_value()

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 libdar::list_entry::get_last_access(), libdar::list_entry::get_last_change(), libdar::list_entry::get_last_modif(), and get_second_value().

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

- datetime.hpp