Ilwis-Objects
1.0
GIS and Remote Sensing framework for data access and processing
|
The Time class utility class that handles all time related things within Ilwis. More...
#include <juliantime.h>
Public Types | |
enum | TimePart { tpYEAR, tpMONTH, tpDAYOFMONTH, tpJULIANDAY, tpDAYOFTHEWEEK, tpDAYOFTHEYEAR, tpWEEKNUMBER, tpHOUR, tpMINUTE, tpSECOND, tpDATE, tpDAYTIME } |
The TimePart enum. | |
Public Member Functions | |
Time (int year, int month, int day, int hour, int minute, double seconds=0) | |
Time (int hour, int minute, double seconds=0) | |
Time (int year, int month=1, int day=1) | |
Time (const time_t time) | |
Time. More... | |
Time (const QString &isostring) | |
Time (const char *isostring) | |
Time (double jd, IlwisTypes m=itDATETIME) | |
Time (const QDateTime &time) | |
Time (const QDate &date) | |
Time (const QTime &tm) | |
Time (const Time &time) | |
virtual | ~Time () |
operator double () const | |
operator QDateTime () const | |
Time & | operator= (double t) |
time_t | toTime_t () const |
toTime_t More... | |
bool | isLeapYear (int year=iUNDEF) const |
virtual double | get (TimePart part) const |
Duration | operator- (const Time &time) const |
Time | operator+ (const Duration &duration) const |
bool | operator< (const Time &time) const |
bool | operator> (const Time &time) const |
bool | operator== (const Time &time) const |
bool | operator!= (const Time &time) const |
void | setValue (const QString &isostring) |
void | setYear (int year) |
void | setMonth (int Mnt) |
void | setDay (int dy) |
void | setHour (int hr) |
void | setMinute (int min) |
void | setSecond (double sec) |
virtual QString | toString (bool local=false, IlwisTypes tp=itUNKNOWN) const |
virtual bool | isValid () const |
IlwisTypes | valueType () const |
void | valueType (IlwisTypes tp) |
Static Public Member Functions | |
static Time | now () |
Protected Attributes | |
double | _julianday |
bool | _valid |
IlwisTypes | _valuetype |
The Time class utility class that handles all time related things within Ilwis.
The time class is build upon the notion of the Julianday (astronomical) which starts its counting at 1 januari, noon, -4713 BC.
In Ilwis the julian day is expressed as a double so fractional days are allowed. This enables the expression of hours, minutes and seconds.
As far as Ilwis is considered the time object is just a number so normal mathematical operations apply to it.
To the outside world the time class is often represented as an ISO 8601 compatible string and this is also one of the notation is expects as input.
Time::Time | ( | int | year, |
int | month, | ||
int | day, | ||
int | hour, | ||
int | minute, | ||
double | seconds = 0 |
||
) |
Creates a new time of type itDATETIME
If 1 of the parameters does not meet the requirements, the time object will be invalid.
The julianday will be generated from these fields.
yr | the year of this time defaults to -4317 |
mnth | the month of this time must be on [1,12], defaults to 1 |
dy | the day of this time must fit within the month specified, defaults to 1 |
hr | the hour of this time must be on [0,24] |
min | the amount of minutes of this time must be on [0,60] |
sec | the amount of seconds of this time must be on [0,60] |
Time::Time | ( | int | hour, |
int | minute, | ||
double | seconds = 0 |
||
) |
Creates a new time of type itTIME
If 1 of the parameters does not meet the requirements, the time object will be invalid.
The julianday will be generated from these fields.
hr | the hour of this time must be on [0,24] |
min | the amount of minutes of this time must be on [0,60] |
sec | the amount of seconds of this time must be on [0,60] |
Time::Time | ( | int | year, |
int | month = 1 , |
||
int | day = 1 |
||
) |
Creates a new time of type itDATE
If 1 of the parameters does not meet the requirements, the time object will be invalid.
The julianday will be generated from these fields.
yr | the year of this time defaults to -4317 |
mnth | the month of this time must be on [1,12], defaults to 1 |
dy | the day of this time must fit within the month specified, defaults to 1 |
Time::Time | ( | const time_t | time | ) |
Time.
time |
Time::Time | ( | const QString & | isostring | ) |
Creates a new Time from an isostring
requires the isostring to be valid
isostring | the isostring with the time |
Time::Time | ( | double | jd, |
IlwisTypes | m = itDATETIME |
||
) |
Creates a new time from an amount of seconds from 0/0/-4712
days | the amount of days after 0/0/-4712 |
Time::Time | ( | const QDateTime & | time | ) |
|
virtual |
Deconstructor
|
virtual |
Query for a single field of this Time.
You can query for:
part | The part of this Time requested (tpX values) |
Reimplemented in Ilwis::Duration.
bool Time::isLeapYear | ( | int | year = iUNDEF | ) | const |
Checks whether the given year is a leapyear
year | the year that has to be checked, if no specified it will look at the julian time of this Time object |
|
virtual |
Checks the validity of this time.
A time is invalid when there is no time set, or 1 or more of the inner members have an invalid value (negative value).
Reimplemented in Ilwis::Duration.
|
static |
Calculates the current time using the time of the system.
Time::operator double | ( | ) | const |
Override of the operator, returns the julianday value of this Time
Time::operator QDateTime | ( | ) | const |
Override of the operator, generates a QDateTime object representing this Time
bool Time::operator!= | ( | const Time & | time | ) | const |
Override of the != operator compares this time with another.
The comparison is based on the Julian Time of both Times.
Requires the Time that has to be added to be valid. (the time parameter)
if this Time is invalid it will simply return false.
time | the time that should be compared with this Time object |
Override of the + operator adds another time to this Time.
The addition is based on the Julian Time of both Times.
Requires the Time that has to be added to be valid. (the time parameter)
if this Time is invalid it will simply return tUNDEF.
time | the time that should be added from this Time object |
Override of the - operator substracts another time from this Time.
The substraction is based on the Julian Time of both Times.
Requires the Time that has to be substracted to be valid. (the time parameter) if this Time is invalid it will simply return tUNDEF.
time | the time that should be substracted from this Time object |
bool Time::operator< | ( | const Time & | time | ) | const |
Override of the < operator compares this time with another.
The comparison is based on the Julian Time of both Times.
Requires the Time that has to be added to be valid. (the time parameter)
if this Time is invalid it will simply return false.
time | the time that should be compared with this Time object |
Time & Time::operator= | ( | double | t | ) |
bool Time::operator== | ( | const Time & | time | ) | const |
Override of the == operator compares this time with another.
The comparison is based on the Julian Time of both Times.
Requires the Time that has to be added to be valid. (the time parameter)
if this Time is invalid it will simply return false.
time | the time that should be compared with this Time object |
bool Time::operator> | ( | const Time & | time | ) | const |
Override of the > operator compares this time with another.
The comparison is based on the Julian Time of both Times.
Requires the Time that has to be added to be valid. (the time parameter)
if this Time is invalid it will simply return false.
time | the time that should be compared with this Time object |
void Time::setDay | ( | int | dy | ) |
Sets the day field of this time.
if day is iUNDEF the julianday will be set to rUNDEF.
If you want to set the fields 1 by 1 you have to start at the biggest field or else they will override each other.
year | the new year of this Time |
void Time::setHour | ( | int | hr | ) |
Sets the hour field of this time.
if hour is iUNDEF the julianday will be set to rUNDEF.
If you want to set the fields 1 by 1 you have to start at the biggest field or else they will override each other.
year | the new year of this Time |
void Time::setMinute | ( | int | min | ) |
Sets the minute field of this time.
if minute is iUNDEF the julianday will be set to rUNDEF.
If you want to set the fields 1 by 1 you have to start at the biggest field or else they will override each other.
year | the new year of this Time |
void Time::setMonth | ( | int | Mnt | ) |
Sets the month field of this time.
if month is iUNDEF the julianday will be set to rUNDEF.
If you want to set the fields 1 by 1 you have to start at the biggest field or else they will override each other.
year | the new year of this Time |
void Time::setSecond | ( | double | sec | ) |
Sets the second field of this time.
if second is iUNDEF the julianday will be set to rUNDEF.
If you want to set the fields 1 by 1 you have to start at the biggest field or else they will override each other.
year | the new year of this Time |
void Time::setValue | ( | const QString & | isostring | ) |
Generates the fields of this time from an iso string.
accepted iso 8601 QStrings:
h,m,s may be fractions. internally they are formatted to a correct int representation
isostring |
void Time::setYear | ( | int | year | ) |
Sets the year field of this time.
if year is iUNDEF the julianday will be set to rUNDEF.
If you want to set the fields 1 by 1 you have to start at the biggest field or else they will override each other.
year | the new year of this Time |
|
virtual |
Translates this type to a string format of one of the following types:
The typ defaults to the value type of this time
local | |
mode |
Reimplemented in Ilwis::Duration.
time_t Time::toTime_t | ( | ) | const |
toTime_t