32 #include <sys/types.h>
45 #include "../my_config.h"
57 class datetime :
public on_pool
62 enum time_unit { tu_nanosecond, tu_microsecond, tu_second };
65 datetime(
const infinint & value = 0) { sec = value; frac = 0; uni = tu_second; };
72 datetime(time_t second, time_t subsec, time_unit unit) { sec = second; frac = subsec; uni = unit;
if(uni == tu_second && subsec != 0)
throw SRC_BUG; };
75 datetime(generic_file &x, archive_version ver) { read(x, ver); };
79 bool operator < (
const datetime & ref)
const;
80 bool operator == (
const datetime & ref)
const;
81 bool operator != (
const datetime & ref)
const {
return ! (*
this == ref); };
82 bool operator >= (
const datetime & ref)
const {
return ! (*
this < ref); };
83 bool operator > (
const datetime & ref)
const {
return ref < *
this; };
84 bool operator <= (
const datetime & ref)
const {
return ref >= *
this; };
87 datetime operator - (
const datetime & ref)
const;
88 datetime operator + (
const datetime & ref)
const;
91 datetime loose_diff(
const datetime & ref)
const;
94 infinint get_second_value()
const {
return sec; };
97 infinint get_subsecond_value(time_unit unit)
const;
100 time_unit get_unit()
const {
return uni; };
108 bool get_value(time_t & second, time_t & subsecond, time_unit unit)
const;
112 void dump(generic_file &x)
const;
115 void read(generic_file &f, archive_version ver);
118 bool is_null()
const {
return sec.is_zero() && frac.is_zero(); };
121 bool is_integer_second()
const {
return frac.is_zero(); };
124 infinint get_storage_size()
const {
return sec.get_storage_size() + frac.get_storage_size() + 1; };
138 void reduce_to_largest_unit()
const;
148 bool is_subsecond_an_integer_value_of(time_unit target, infinint & newval)
const;
151 static time_unit min(time_unit a, time_unit b);
152 static time_unit max(time_unit a, time_unit b);
153 static const char time_unit_to_char(time_unit a);
154 static time_unit char_to_time_unit(
const char a);
160 static infinint get_scaling_factor(time_unit source, time_unit dest);
163 static infinint how_much_to_make_1_second(time_unit unit);
archive_version db2archive_version(unsigned char db_version)
converts dar_manager database version to dar archive version in order to properly read time fields ...
switch module to limitint (32 ou 64 bits integers) or infinint
class archive_version that rules which archive format to follow
this is the base class of object that can be allocated on a memory pool
libdar namespace encapsulate all libdar symbols