#include <date.h>
Public Member Functions | |
Date (int year=1970, int month=1, int day=1, int hour=0, int min=0, int sec=0) | |
Date (const time_t &tm) | |
Date (const double &tm) | |
~Date () | |
Date & | operator= (const Date &d) |
Date | operator+ (const double &time) |
bool | operator== (const Date &d) const |
bool | operator!= (const Date &d) const |
bool | operator<= (const Date &d) const |
bool | operator>= (const Date &d) const |
bool | operator< (const Date &d) const |
bool | operator> (const Date &d) const |
bool | is_epoch_start () const |
check is the date is the start of the UNIX epoch time (default) | |
const int | get_sec () const |
const int | get_min () const |
const int | get_hour () const |
const int | get_day () const |
const int | get_month () const |
const int | get_year () const |
const int | get_yday () const |
const bool | is_the_same_day (const Date &d) |
void | set_julian_time (const double &julian_time) |
const double | get_julian_time () |
const double | get_TAI93_time () const |
access to the time in sec using the TAI (International Atomic Time) convention : seconds from Jan. 1, 1993 | |
void | set_TAI93_time (const double &TAI_time) |
set the date using a TAI time (number of seconds passed since the 1993/01/01) | |
const double | get_ECMWF_time () const |
access to the time in hour using the ECMWF convention (number of hours from 1900/01/01 at 00:00:00) | |
void | set_ECMWF_time (const double &time) |
set the date using the ECMWF convention (number of hours from 1900/01/01 at 00:00:00) | |
void | set_date (const int &_year=1970, const int &_month=1, const int &_day=1, const int &_hour=0, const int &_min=0, const int &_sec=0) |
void | set_date_str (const string &s="", const char *_format="") |
const string | get_date_str (const char *_format="") |
return the date as a formatted string | |
void | set_epoch_time (const time_t &_epoch_time) |
time_t | get_epoch_time () const |
return the date using the UNIX epoch time convention (number of seconds passed since the 1970/01/01) | |
void | print () const |
string | to_string () const |
Static Public Member Functions | |
static void | init_leap_sec_table () |
initialize the static table of UTC to TAI leap seconds. This method must updated | |
static double | get_tai93_leap_sec (const Date &d) |
compute the number of leap seconds between a TAI93 and UTC time at the given date | |
static double | get_tai_leap_sec (const Date &d) |
compute the number of leap seconds between a TAI70 and UTC time at the given date | |
static const vector< Date > | get_days (const Date &start, const Date &end) |
list the days between the start date and end date (included) as a vector of "YYYY_MM_DD" strings | |
static const int | get_nb_day (const int &month, const int &year) |
static int | get_day_number (const int &year, const int &month, int &day) |
static void | get_day_range (const int &year, const int &month, int &first, int &last) |
static const string | get_month_string (const int _month) |
static time_t | get_epoch_time (const char *s_date, const char *format) |
return the date using the UNIX epoch time convention (number of seconds passed since the 1970/01/01) | |
Static Public Attributes | |
static const int | nsec_tai93_to_utc_start = 27 |
Friends | |
std::ostream & | operator<< (std::ostream &stream, const Date &date) |
Manages the manipulation of dates. REM :
Date::Date | ( | int | year = 1970 , |
|
int | month = 1 , |
|||
int | day = 1 , |
|||
int | hour = 0 , |
|||
int | min = 0 , |
|||
int | sec = 0 | |||
) |
Constructor using "human dates"
year | the year | |
month | the month | |
day | the day | |
hour | the hour | |
min | the minutes | |
sec | the seconds |
References set_date().
Date::Date | ( | const time_t & | tm | ) |
constructor using UNIX epoch time
tm | a time_t UNIX date |
Date::Date | ( | const double & | tm | ) |
constructor using UNIX epoch time, but with a double cast
tm | a time_t UNIX date converted to a double |
Date::~Date | ( | ) | [inline] |
Destructor
const string Date::get_date_str | ( | const char * | _format = "" |
) |
return the date as a formatted string
_format | the format. See strftime documentation for format description |
const int Date::get_day | ( | ) | const |
the number of the day of this
Referenced by get_nb_day(), MODISFileData::get_radix(), is_the_same_day(), and DARDARFileData::load_geolocation_data().
int Date::get_day_number | ( | const int & | year, | |
const int & | month, | |||
int & | day | |||
) | [static] |
return the day number spend since the start of year
year | the number of the year, using christian numeration (ex : 2005) | |
month | the number of the month (1->12) | |
day | the number of the day |
References get_yday().
void Date::get_day_range | ( | const int & | year, | |
const int & | month, | |||
int & | first, | |||
int & | last | |||
) | [static] |
get the day number range for a month. Rem : the 1st january has the number 0 (POSIX convention)
year | the year, using 4 digits (ex 2005) | |
month | the month number (0->11) | |
first | the number (from the start of year) of the 1st day of the month (0->365) | |
last | the number (from the start of year) of the last day of the month (0->365) |
References get_month_string().
list the days between the start date and end date (included) as a vector of "YYYY_MM_DD" strings
start | the start date | |
end | the end date |
References get_epoch_time(), and set_epoch_time().
const double Date::get_ECMWF_time | ( | ) | const |
access to the time in hour using the ECMWF convention (number of hours from 1900/01/01 at 00:00:00)
time_t Date::get_epoch_time | ( | const char * | s_date, | |
const char * | format | |||
) | [static] |
return the date using the UNIX epoch time convention (number of seconds passed since the 1970/01/01)
s | a string representing a date | |
_format | a string formatter using the strptime convention |
References get_epoch_time(), and set_date_str().
const int Date::get_hour | ( | ) | const |
the number of hours of this
const double Date::get_julian_time | ( | ) |
convert the Date represented by this into a julian date.
const int Date::get_min | ( | ) | const |
the number of minutes of this
const int Date::get_month | ( | ) | const |
the number of the month of this
Referenced by MODISFileData::get_radix(), is_the_same_day(), and DARDARFileData::load_geolocation_data().
const string Date::get_month_string | ( | const int | _month | ) | [static] |
return a string representing the month passed in parametre, using 2 digits. In other words, if the month if less than 10, it will return 0+the_number_of_the_month. If more than 10, it will just convert the in month into a string.
_month | the number of the month |
Referenced by get_day_range(), and MODISFileData::get_radix().
const int Date::get_nb_day | ( | const int & | month, | |
const int & | year | |||
) | [static] |
return the number of days for the given month of the given year
month | the number of the month (1->12) | |
year | the number of the year, using christian numeration (ex : 2005) |
References get_day(), get_TAI93_time(), and set_TAI93_time().
const int Date::get_sec | ( | ) | const |
the number of seconds of this
double Date::get_tai93_leap_sec | ( | const Date & | d | ) | [static] |
compute the number of leap seconds between a TAI93 and UTC time at the given date
d | a date |
References get_tai_leap_sec().
Referenced by DARDARFileData::load_geolocation_data().
const double Date::get_TAI93_time | ( | ) | const |
access to the time in sec using the TAI (International Atomic Time) convention : seconds from Jan. 1, 1993
Referenced by FileData::contain_time(), IIRFileData::contains_data_at(), get_nb_day(), PARASOLFileData::get_record_time(), MeteoFileData::get_time_index(), MeteoFileData::get_time_max(), MeteoFileData::get_time_min(), and DARDARFileData::load_geolocation_data().
double Date::get_tai_leap_sec | ( | const Date & | d | ) | [static] |
compute the number of leap seconds between a TAI70 and UTC time at the given date
d | a date |
References get_epoch_time(), and init_leap_sec_table().
Referenced by get_tai93_leap_sec().
const int Date::get_yday | ( | ) | const |
the number of days passed since the start of year
Referenced by get_day_number().
const int Date::get_year | ( | ) | const |
the year of this
Referenced by MODISFileData::get_radix(), is_the_same_day(), and DARDARFileData::load_geolocation_data().
bool Date::is_epoch_start | ( | ) | const [inline] |
check is the date is the start of the UNIX epoch time (default)
const bool Date::is_the_same_day | ( | const Date & | d | ) |
check is the 2 dates are issued of the same day (same day; month and year)
References get_day(), get_month(), and get_year().
bool Date::operator!= | ( | const Date & | d | ) | const |
Date Date::operator+ | ( | const double & | time | ) |
A time in seconds addition operator
time | a time in secs that must be added to this |
bool Date::operator< | ( | const Date & | d | ) | const |
bool Date::operator<= | ( | const Date & | d | ) | const |
bool Date::operator== | ( | const Date & | d | ) | const |
bool Date::operator> | ( | const Date & | d | ) | const |
bool Date::operator>= | ( | const Date & | d | ) | const |
void Date::print | ( | ) | const |
print out the date
void Date::set_date | ( | const int & | _year = 1970 , |
|
const int & | _month = 1 , |
|||
const int & | _day = 1 , |
|||
const int & | _hour = 0 , |
|||
const int & | _min = 0 , |
|||
const int & | _sec = 0 | |||
) |
build the date with the day number + the month number.
_year | the year (the real one, not from 1970 or stuff like this. ex : 2005) | |
_month | the month in range (1->12) | |
_day | the day in range (1->31) | |
_hour | the hour in range (0->23) | |
_min | the minutes in range (0->59) | |
_sec | the seconds in range (0->59). In fact 60 is possible du to the Posix norma, but it's preferable not to use it in this case. |
Referenced by Date(), and DARDARFileData::load_geolocation_data().
void Date::set_date_str | ( | const string & | s = "" , |
|
const char * | _format = "" | |||
) |
build the date using a formatted string.
s | the formatted string containing the date | |
_format | the format. See strptime documentation for format description |
Referenced by get_epoch_time(), PARASOLFileData::get_record_time(), MODISFileData::parse_filename(), GMAOFileData::parse_filename(), and ECMWFFileData::parse_filename().
void Date::set_ECMWF_time | ( | const double & | time | ) |
set the date using the ECMWF convention (number of hours from 1900/01/01 at 00:00:00)
time | a time in hours since the 1900/01/01 at 00:00:00 |
void Date::set_epoch_time | ( | const time_t & | _epoch_time | ) |
set the date using an epoch (ie UNIX) time (number of seconds passed since the 1970/01/01)
_epoch_time | a time in UNIX convention |
Referenced by get_days().
void Date::set_julian_time | ( | const double & | julian_time | ) |
set the time using a julian date (in float days since 1/1/-4712 at 12h00)
julian_time | the julian date in year |
void Date::set_TAI93_time | ( | const double & | TAI_time | ) |
set the date using a TAI time (number of seconds passed since the 1993/01/01)
TAI_time | a time in TAI convention |
Referenced by get_nb_day().