Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

PLearn::PDateTime Class Reference

#include <PDateTime.h>

Collaboration diagram for PLearn::PDateTime:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 PDateTime ()
 Create a missing date by default.

 PDateTime (short the_year, unsigned char the_month, unsigned char the_day)
 Create a date only, with time assumed to be midnight.

 PDateTime (int the_year, int the_month, int the_day)
 PDateTime (short the_year, unsigned char the_month, unsigned char the_day, unsigned char the_hour, unsigned char the_min, unsigned char the_sec)
 Create a full date/time.

 PDateTime (int the_year, int the_month, int the_day, int the_hour, int the_min, int the_sec)
 PDateTime (double julian_day)
 convert a Julian day into a PDateTime.

 PDateTime (string datetime)
 Convert a string in "YYYY/MM/DD" or "YYYY/MM/DD hh:mm:ss" into a PDateTime.

bool isMissing () const
 Missing date/time handling.

void setMissing ()
 returns the date in the format yyyy/mm/dd hh:mm:ss

string info () const
bool operator== (const PDateTime &rhs) const
 Equality comparison.

bool operator!= (const PDateTime &rhs) const
bool operator< (const PDateTime &rhs) const
bool operator<= (const PDateTime &rhs) const
bool operator> (const PDateTime &rhs) const
bool operator>= (const PDateTime &rhs) const
double toJulianDay () const

Public Attributes

short year
 ex: 1983, 2001, -350, ...

unsigned char month
 1..12

unsigned char day
 1..31

unsigned char hour
 00..23

unsigned char min
 00..59

unsigned char sec
 00..61, allowing for leap seconds (!)


Detailed Description

PDateTime must be a concrete class with no virtual function. Hence it MUST NOT UNDER ANY CONSIDERATION UNDER HEAVY PRISON PENALTY derive from Object. The reason that PDateTime is different from the related PDate (which stores only a date) is that some clients (e.g. SimpleDB and friends) make fairly stringent assumptions on the memory layout of a PDate, and leave no room for time. Also, a PDateTime should really be considered a "time-point", and for added precision converts itself to a double.

Definition at line 60 of file PDateTime.h.


Constructor & Destructor Documentation

PLearn::PDateTime::PDateTime  ) 
 

Create a missing date by default.

Definition at line 47 of file PDateTime.cc.

References setMissing().

PLearn::PDateTime::PDateTime short  the_year,
unsigned char  the_month,
unsigned char  the_day
[inline]
 

Create a date only, with time assumed to be midnight.

Definition at line 74 of file PDateTime.h.

References day, hour, min, month, sec, and year.

PLearn::PDateTime::PDateTime int  the_year,
int  the_month,
int  the_day
[inline]
 

Definition at line 78 of file PDateTime.h.

References day, hour, min, month, sec, and year.

PLearn::PDateTime::PDateTime short  the_year,
unsigned char  the_month,
unsigned char  the_day,
unsigned char  the_hour,
unsigned char  the_min,
unsigned char  the_sec
[inline]
 

Create a full date/time.

Definition at line 83 of file PDateTime.h.

References day, hour, min, month, sec, and year.

PLearn::PDateTime::PDateTime int  the_year,
int  the_month,
int  the_day,
int  the_hour,
int  the_min,
int  the_sec
[inline]
 

Definition at line 89 of file PDateTime.h.

References day, hour, min, month, sec, and year.

PLearn::PDateTime::PDateTime double  julian_day  ) 
 

convert a Julian day into a PDateTime.

Day 0 of the Julian calendar is about 6000 years ago... The julian day is passed as a DOUBLE, to allow specifying hours/minutes/seconds as a FRACTION of days.

Definition at line 52 of file PDateTime.cc.

References day, PLearn::double_to_hhmmss(), hour, min, month, sec, and year.

PLearn::PDateTime::PDateTime string  datetime  ) 
 

Convert a string in "YYYY/MM/DD" or "YYYY/MM/DD hh:mm:ss" into a PDateTime.

The format has to match exactly.

Definition at line 75 of file PDateTime.cc.

References day, hour, PLearn::min(), min, month, PLERROR, sec, PLearn::toint(), and year.


Member Function Documentation

string PLearn::PDateTime::info  )  const
 

Definition at line 109 of file PDateTime.cc.

References day, hour, min, month, PLearn::right(), sec, slash, PLearn::tostring(), and year.

Referenced by PLearn::operator<<().

bool PLearn::PDateTime::isMissing  )  const
 

Missing date/time handling.

Definition at line 97 of file PDateTime.cc.

References day, month, and year.

Referenced by PLearn::datetime_to_double().

bool PLearn::PDateTime::operator!= const PDateTime rhs  )  const [inline]
 

Definition at line 116 of file PDateTime.h.

bool PLearn::PDateTime::operator< const PDateTime rhs  )  const [inline]
 

Definition at line 120 of file PDateTime.h.

References PLearn::datetime_to_double().

bool PLearn::PDateTime::operator<= const PDateTime rhs  )  const [inline]
 

Definition at line 125 of file PDateTime.h.

bool PLearn::PDateTime::operator== const PDateTime rhs  )  const [inline]
 

Equality comparison.

Definition at line 111 of file PDateTime.h.

References day, hour, min, month, sec, and year.

bool PLearn::PDateTime::operator> const PDateTime rhs  )  const [inline]
 

Definition at line 129 of file PDateTime.h.

bool PLearn::PDateTime::operator>= const PDateTime rhs  )  const [inline]
 

Definition at line 133 of file PDateTime.h.

void PLearn::PDateTime::setMissing  ) 
 

returns the date in the format yyyy/mm/dd hh:mm:ss

Definition at line 102 of file PDateTime.cc.

References day, month, and year.

Referenced by PDateTime().

double PLearn::PDateTime::toJulianDay  )  const
 

Convert a PDateTime into a Julian day. See http://quasar.as.utexas.edu/BillInfo/JulianDatesG.html (if still existing...) for details.

Definition at line 119 of file PDateTime.cc.

References day, PLearn::hhmmss_to_double(), hour, min, month, PLERROR, sec, and year.


Member Data Documentation

unsigned char PLearn::PDateTime::day
 

1..31

Definition at line 65 of file PDateTime.h.

Referenced by PLearn::datetime_to_double(), PLearn::double_to_datetime(), info(), isMissing(), operator==(), PDateTime(), setMissing(), and toJulianDay().

unsigned char PLearn::PDateTime::hour
 

00..23

Definition at line 66 of file PDateTime.h.

Referenced by PLearn::datetime_to_double(), PLearn::double_to_datetime(), info(), operator==(), PDateTime(), and toJulianDay().

unsigned char PLearn::PDateTime::min
 

00..59

Definition at line 67 of file PDateTime.h.

Referenced by PLearn::datetime_to_double(), PLearn::double_to_datetime(), info(), operator==(), PDateTime(), and toJulianDay().

unsigned char PLearn::PDateTime::month
 

1..12

Definition at line 64 of file PDateTime.h.

Referenced by PLearn::datetime_to_double(), PLearn::double_to_datetime(), info(), isMissing(), operator==(), PDateTime(), setMissing(), and toJulianDay().

unsigned char PLearn::PDateTime::sec
 

00..61, allowing for leap seconds (!)

Definition at line 68 of file PDateTime.h.

Referenced by PLearn::datetime_to_double(), PLearn::double_to_datetime(), info(), operator==(), PDateTime(), and toJulianDay().

short PLearn::PDateTime::year
 

ex: 1983, 2001, -350, ...

Definition at line 63 of file PDateTime.h.

Referenced by PLearn::datetime_to_double(), PLearn::double_to_datetime(), info(), isMissing(), operator==(), PDateTime(), setMissing(), and toJulianDay().


The documentation for this class was generated from the following files:
Generated on Tue Aug 17 16:22:35 2004 for PLearn by doxygen 1.3.7