2.0.0b10
catchment modelling framework
|
A time class, used to pass around current modelling times. More...
A time class, used to pass around current modelling times.
Timespans and dates in cmf are used with a special object, called Time. An extra class has the advantage, that the user does not have to remember, which unit of time he or she uses or what time unit is accepted by a specific function of the model. Arithmetic and boolean operators are supported by Time. Internally the time classes stores the time as integer milliseconds, therefore rounding issues will only appear at very small time ranges. Absolute time (like dates) are represented as milliseconds gone by from Dec, 31st 1899. Microsoft Excel dates are represented as days from that time, using floating point numbers, therefore it is very simple to convert Excel time representations to cmf time.
Another object is Date, which is doesn't provide the operators, but has a nice printed version and some special date functions, like day of year (DOY) and provides access to the current hour of day and so on, which only applyto dates and not to time spans. You can convert Time to Date an vice versa. The printing is not culture aware and uses the European representation. If you use the Python standard library datetime, conversion between Python time and cmf time is possible
Creating absolute time values (dates)
Creating time spans
In principle, there are three ways to create time spans. One is to use one of the static functions, another is to multiply an existing time span (like one of the build in constants) or to substrate two absolute times.
Available constants
Available operators:
Conversions
Converting to python datetime
Converting to numbers
Creating time ranges
Public Member Functions | |
Constructors | |
Time (int day, int month, int year, int hour=0, int minute=0, int second=0, int ms=0) | |
Construction from date and stores the time as Excel-Time (0 = 31.12.1899 0:00:00) | |
Time (Date date) | |
Conversion constructor. | |
Time (const Time &t) | |
Copy constructor. | |
Time () | |
Standard constructor. | |
Time unit conversion | |
double | AsDays () const |
Time in days. | |
double | AsHours () const |
Time in hours. | |
double | AsMinutes () const |
Time in minutes. | |
double | AsSeconds () const |
Time in seconds. | |
long long | AsMilliseconds () const |
Time in milliseconds. | |
Arithmetic operators | |
Time | operator+ (const Time &t1) const |
Time = Time + Time. | |
Time | operator- (const Time &t1) const |
Time = Time - Time. | |
Time | operator+= (const Time &t1) |
Time += Time. | |
Time | operator-= (const Time &t1) |
Time -= Time. | |
Time | operator* (double x) const |
Time = Time * double. | |
Time | operator/ (double x) const |
Time = Time / double. | |
Time | operator% (const Time &t1) const |
Time = Time % Time. | |
Time & | operator*= (double x) |
Time *= double. | |
Time & | operator/= (double x) |
Time /= double. | |
Time | operator* (long long x) const |
Time = Time * int. | |
Time | operator/ (long long x) const |
Time = Time / int. | |
Time & | operator*= (long long x) |
Time *= int. | |
Time & | operator/= (long long x) |
Time /= int. | |
Time | operator* (int x) const |
Time = Time * int. | |
Time | operator/ (int x) const |
Time = Time / int. | |
Time & | operator*= (int x) |
Time *= int. | |
Time & | operator/= (int x) |
Time /= int. | |
Time & | operator%= (const Time &t1) |
Time %= Time. | |
double | operator/ (const Time &t1) const |
double = Time / Time | |
long long | times_in (const Time &t1) const |
Returns the number of times this is included in t1. | |
Boolean Operators | |
bool | operator< (const Time &t1) const |
bool = Time < Time | |
bool | operator> (const Time &t1) const |
bool = Time > Time | |
bool | operator<= (const Time &t1) const |
bool = Time <= Time | |
bool | operator>= (const Time &t1) const |
bool = Time >= Time | |
bool | operator== (const Time &t1) const |
bool = Time == Time | |
bool | operator!= (const Time &t1) const |
bool = Time != Time | |