Medial Code Documentation
Loading...
Searching...
No Matches
Public Member Functions | Data Fields | Static Public Attributes
MedTime Class Reference

The following is a class to handle time conversions There's a global instance of it declared below (med_time_convert) to be used in conversions. More...

#include <MedTime.h>

Public Member Functions

bool is_valid_date (int date) const
 
int convert_times (int from_type, int to_type, int in_time)
 Converts time formats.
 
int convert_times (int from_type, int to_type, double in_time)
 
double convert_times_D (int from_type, int to_type, int in_time)
 
double convert_times_D (int from_type, int to_type, double in_time)
 
string convert_times_S (int from_type, int to_type, int in_time)
 
void init_time_tables ()
 init of time table
 
int convert_date (int to_type, int in_time)
 Converts time formats from date format as input.
 
int convert_datetime (int to_type, string in_time)
 converts from YYYYMMDDHHMI format
 
int convert_datetime_safe (int to_type, string in_time, char handle_ilegal_date=2)
 converts from YYYYMMDDHHMI format include warning in dates before 1900 - for loading.
 
int convert_years (int to_type, int in_time)
 
int convert_months (int to_type, int in_time)
 
int convert_days (int to_type, int in_time)
 
int convert_hours (int to_type, int in_time)
 
int convert_minutes (int to_type, int in_time)
 
int add_subtruct_days (int in_time, int delta_days)
 
int string_to_type (const string &str)
 Convert string to type.
 
string type_to_string (int type)
 Converts type to string.
 
int diff_times (int d1, int d2, int in_type, int out_type)
 
double diff_times_D (int d1, int type1, int d2, int type2, int out_type)
 
int diff_times (int d1, int type1, int d2, int type2, int out_type)
 
double get_age (int t, int type_t, int byear)
 
double get_age_from_bdate (int t, int type_t, int bdate)
 
int add_subtract_time (int in_time, int in_type, int delta_time, int delta_type)
 subtract time (truncating negative values)
 

Data Fields

vector< int > YearsMonths2Days
 
vector< int > Years2Days
 
vector< int > Days2Years
 
vector< int > Days2Months
 
vector< int > Days2Date
 
vector< int > days2month = { 0,31,59,90,120,151,181,212,243,273,304,334,365 }
 

Static Public Attributes

static const int Undefined = 0
 undefined time unit
 
static const int Date = 1
 dates are in full regular format YYYYMMDD
 
static const int Years = 2
 years since 1900 (not since 0!)
 
static const int Months = 3
 months since 1900/01/01
 
static const int Days = 4
 days since 1900/01/01
 
static const int Hours = 5
 hours since 1900/01/01
 
static const int Minutes = 6
 minutes since 1900/01/01
 
static const int DateTimeString = 7
 string only format "YYYYMMDDHHMI"
 
static const int MIN_DATE_SUPPORT = 19000000
 minimal date support
 

Detailed Description

The following is a class to handle time conversions There's a global instance of it declared below (med_time_convert) to be used in conversions.

Member Function Documentation

◆ convert_date()

int MedTime::convert_date ( int  to_type,
int  in_time 
)

Converts time formats from date format as input.

usefull for converting dates to days from 1900 for example to calculate days diff.

Returns
returns the time in new format

◆ convert_datetime()

int MedTime::convert_datetime ( int  to_type,
string  in_time 
)

converts from YYYYMMDDHHMI format

handles YYYYMMDD and YYYY-MM-DD HH:MI:SS formats

◆ convert_datetime_safe()

int MedTime::convert_datetime_safe ( int  to_type,
string  in_time,
char  handle_ilegal_date = 2 
)

converts from YYYYMMDDHHMI format include warning in dates before 1900 - for loading.

handle_ilegal_date [0 - hanldes quitely truncate to 1900, 1- shows warning and truncate, 2 - throws error]

◆ convert_times()

int MedTime::convert_times ( int  from_type,
int  to_type,
int  in_time 
)

Converts time formats.

usefull for converting dates to days from 1900 for example to calculate days diff.

Returns
returns the time in new format

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