32 #include <sys/types.h>
45 #include "../my_config.h"
55 class datetime :
public on_pool
60 enum time_unit { tu_nanosecond, tu_microsecond, tu_second };
63 datetime(
const infinint & value = 0) { val = value; uni = tu_second; };
70 datetime(time_t second, time_t subsec, time_unit unit);
73 datetime(generic_file &x, archive_version ver) { read(x, ver); };
77 bool operator < (
const datetime & ref)
const;
78 bool operator == (
const datetime & ref)
const;
79 bool operator != (
const datetime & ref)
const {
return ! (*
this == ref); };
80 bool operator >= (
const datetime & ref)
const {
return ! (*
this < ref); };
81 bool operator > (
const datetime & ref)
const {
return ref < *
this; };
82 bool operator <= (
const datetime & ref)
const {
return ref >= *
this; };
85 void operator -= (
const datetime & ref);
87 datetime operator - (
const datetime & ref)
const { datetime tmp(*
this); tmp -= ref;
return tmp; };
88 datetime operator + (
const datetime & ref)
const { datetime tmp(*
this); tmp += ref;
return tmp; };
91 bool loose_equal(
const datetime & ref)
const;
94 datetime loose_diff(
const datetime & ref)
const;
97 infinint get_second_value()
const { infinint sec, sub; get_value(sec, sub, uni);
return sec; };
100 infinint get_subsecond_value(time_unit unit)
const;
103 time_unit get_unit()
const {
return uni; };
111 bool get_value(time_t & second, time_t & subsecond, time_unit unit)
const;
115 void dump(generic_file &x)
const;
118 void read(generic_file &f, archive_version ver);
121 bool is_null()
const {
return val.is_zero(); };
124 bool is_integer_second()
const {
return (uni == tu_second); };
127 infinint get_storage_size()
const;
130 void nullify() { val = 0; uni = tu_second ; };
143 void reduce_to_largest_unit()
const;
144 void get_value(infinint & sec, infinint & sub, time_unit unit)
const;
145 void build(
const infinint & sec,
const infinint & sub, time_unit unit);
147 static time_unit min(time_unit a, time_unit b);
148 static time_unit max(time_unit a, time_unit b);
149 static const char time_unit_to_char(time_unit a);
150 static time_unit char_to_time_unit(
const char a);
156 static const infinint & get_scaling_factor(time_unit source, time_unit dest);
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