Ilwis-Objects  1.0
GIS and Remote Sensing framework for data access and processing
 All Classes Functions Enumerations Pages
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Ilwis::Time Class Reference

The Time class utility class that handles all time related things within Ilwis. More...

#include <juliantime.h>

Inheritance diagram for Ilwis::Time:
Ilwis::Duration

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
 
Timeoperator= (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 Member Functions

void checkDate (int year, int month, int day)
 
void checkTime (int hour, int minute, double seconds)
 
double gregorianToJulian (int year, int month, int day, int hour, int minutes, double seconds) const
 
void julianToGregorian (int &year, int &month, int &day, int &hour, int &minutes, double &seconds) const
 
int julianyearday (int year, int month, int day) const
 
int tolong (double val) const
 
void parseOrdinalDate (int ordinal, int year, int &month, int &day)
 
void parseYearPart (const QString &yearpart, int &year, int &month, int &day)
 
void parseDayPart (const QString &dayPart, int &hours, int &minutes, double &seconds)
 
void parseIsoString (const QString &isostring, int &year, int &month, int &day, int &hours, int &minutes, double &seconds)
 

Protected Attributes

double _julianday
 
bool _valid
 
IlwisTypes _valuetype
 

Detailed Description

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.

Constructor & Destructor Documentation

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.

Parameters
yrthe year of this time defaults to -4317
mnththe month of this time must be on [1,12], defaults to 1
dythe day of this time must fit within the month specified, defaults to 1
hrthe hour of this time must be on [0,24]
minthe amount of minutes of this time must be on [0,60]
secthe 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.

Parameters
hrthe hour of this time must be on [0,24]
minthe amount of minutes of this time must be on [0,60]
secthe 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.

Parameters
yrthe year of this time defaults to -4317
mnththe month of this time must be on [1,12], defaults to 1
dythe day of this time must fit within the month specified, defaults to 1
Time::Time ( const time_t  time)

Time.

Parameters
time
Time::Time ( const QString &  isostring)

Creates a new Time from an isostring
requires the isostring to be valid

Parameters
isostringthe isostring with the time
Time::Time ( double  jd,
IlwisTypes  m = itDATETIME 
)

Creates a new time from an amount of seconds from 0/0/-4712

Parameters
daysthe amount of days after 0/0/-4712
Time::Time ( const QDateTime &  time)

Creates a new Time from a QDateTime object.
This requires the relevant fields from the QDateTime to be set.

Parameters
timeQDateTime that should be used to create this Time
Time::~Time ( )
virtual

Deconstructor

Member Function Documentation

double Time::get ( TimePart  part) const
virtual

Query for a single field of this Time.
You can query for:

  • tpDATE
  • tpDAYTIME
  • tpYEAR
  • tpMONTH
  • tpDAYOFMONTH
  • tpJULIANDAY
  • tpDAYOFTHEWEEK
  • tpHOUR
  • tpMINUTE
  • tpSECOND will return rUNDEF if this Time object is invalid / the requested fields are not available
Parameters
partThe part of this Time requested (tpX values)
Returns
The value of the requested part

Reimplemented in Ilwis::Duration.

bool Time::isLeapYear ( int  year = iUNDEF) const

Checks whether the given year is a leapyear

Parameters
yearthe year that has to be checked, if no specified it will look at the julian time of this Time object
Returns
true if the given year is a leapyear
bool Time::isValid ( ) const
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).

Returns
true if this time is valid (the value within this time)

Reimplemented in Ilwis::Duration.

Time Time::now ( )
static

Calculates the current time using the time of the system.

Returns
the time at the moment of the call
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.

Parameters
timethe time that should be compared with this Time object
Returns
true when the juliandate of this time is not equal to the other Time 's
Time Time::operator+ ( const Duration duration) const

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.

Parameters
timethe time that should be added from this Time object
Returns
this after substraction
Duration Time::operator- ( const Time time) const

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.

Parameters
timethe time that should be substracted from this Time object
Returns
this after substraction
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.

Parameters
timethe time that should be compared with this Time object
Returns
true when the juliandate of this time is smaller than the other Time 's
Time & Time::operator= ( double  t)

Override of the = operator. sets the JulianDate of this Time to t

Parameters
tthe new julian date of this Time
Returns
*this
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.

Parameters
timethe time that should be compared with this Time object
Returns
true when the juliandate of this time is equal to0 the other Time 's
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.

Parameters
timethe time that should be compared with this Time object
Returns
true when the juliandate of this time is bigger than the other Time 's
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.

Parameters
yearthe 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.

Parameters
yearthe 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.

Parameters
yearthe 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.

Parameters
yearthe 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.

Parameters
yearthe 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:

  • YYYY[-MM[-DD[Thh[:mm[:s[Z]]]]]]
  • YYYY[MM[DD[Thh[:mm[:s[Z]]]]]

h,m,s may be fractions. internally they are formatted to a correct int representation

Parameters
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.

Parameters
yearthe new year of this Time
QString Time::toString ( bool  local = false,
IlwisTypes  tp = itUNKNOWN 
) const
virtual

Translates this type to a string format of one of the following types:

  • itDATE
  • itDATETIME
  • itTIME

The typ defaults to the value type of this time

Parameters
local
mode
Returns

Reimplemented in Ilwis::Duration.

time_t Time::toTime_t ( ) const

toTime_t

Returns

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