Logo Search packages:      
Sourcecode: poco version File versions  Download package

Poco::DateTime Class Reference

#include <DateTime.h>

List of all members.

Detailed Description

This class represents an instant in time, expressed in years, months, days, hours, minutes, seconds and milliseconds based on the Gregorian calendar. The class is mainly useful for conversions between UTC, Julian day and Gregorian calendar dates.

Conversion calculations are based on algorithms collected and described by Peter Baum at http://vsg.cape.com/~pbaum/date/date0.htm

Internally, this class stores a date/time in two forms (UTC and broken down) for performance reasons. Only use this class for conversions between date/time representations. Use the Timestamp class for everything else.

Notes: Zero is a valid year (in accordance with ISO 8601 and astronomical year numbering) Year zero (0) is a leap year Negative years (years preceding 1 BC) are not supported

For more information, please see: http://en.wikipedia.org/wiki/Gregorian_Calendar http://en.wikipedia.org/wiki/Julian_day http://en.wikipedia.org/wiki/UTC http://en.wikipedia.org/wiki/ISO_8601

Definition at line 51 of file DateTime.h.

Public Types

enum  DaysOfWeek {
 Symbolic names for week day numbers (0 to 6).
enum  Months {
 Symbolic names for month numbers (1 to 12).

Public Member Functions

DateTimeassign (int year, int month, int day, int hour=0, int minute=0, int second=0, int millisecond=0, int microseconds=0)
 Assigns a Julian day.
 DateTime (const DateTime &dateTime)
 DateTime (Timestamp::UtcTimeVal utcTime, Timestamp::TimeDiff diff)
 Creates a DateTime for the given Julian day.
 DateTime (double julianDay)
 DateTime (int year, int month, int day, int hour=0, int minute=0, int second=0, int millisecond=0, int microsecond=0)
 DateTime (const Timestamp &timestamp)
 Creates a DateTime for the current date and time.
int day () const
int dayOfWeek () const
 Returns the day witin the month (1 to 31).
int dayOfYear () const
int hour () const
int hourAMPM () const
 Returns the hour (0 to 23).
bool isAM () const
 Returns the hour (0 to 12).
bool isPM () const
 Returns true if hour < 12;.
double julianDay () const
 Returns the microsecond (0 to 999).
int microsecond () const
 Returns the millisecond (0 to 999).
int millisecond () const
 Returns the second (0 to 59).
int minute () const
 Returns true if hour >= 12.
int month () const
 Returns the year.
bool operator!= (const DateTime &dateTime) const
DateTime operator+ (const Timespan &span) const
DateTimeoperator+= (const Timespan &span)
Timespan operator- (const DateTime &dateTime) const
DateTime operator- (const Timespan &span) const
DateTimeoperator-= (const Timespan &span)
bool operator< (const DateTime &dateTime) const
bool operator<= (const DateTime &dateTime) const
DateTimeoperator= (double julianDay)
 Assigns a Timestamp.
DateTimeoperator= (const Timestamp &timestamp)
 Assigns another DateTime.
DateTimeoperator= (const DateTime &dateTime)
 Destroys the DateTime.
bool operator== (const DateTime &dateTime) const
bool operator> (const DateTime &dateTime) const
bool operator>= (const DateTime &dateTime) const
int second () const
 Returns the minute (0 to 59).
void swap (DateTime &dateTime)
Timestamp timestamp () const
 Returns the julian day for the date and time.
Timestamp::UtcTimeVal utcTime () const
 Returns the date and time expressed as a Timestamp.
int week (int firstDayOfWeek=MONDAY) const
 Returns the month (1 to 12).
int year () const
 Swaps the DateTime with another one.
 ~DateTime ()
 Copy constructor. Creates the DateTime from another one.

Static Public Member Functions

static int daysOfMonth (int year, int month)
static bool isLeapYear (int year)
static bool isValid (int year, int month, int day, int hour=0, int minute=0, int second=0, int millisecond=0, int microsecond=0)

Protected Member Functions

void computeDaytime ()
void computeGregorian (double julianDay)
 Computes the UTC time for a Julian day.

Static Protected Member Functions

static double toJulianDay (int year, int month, int day, int hour=0, int minute=0, int second=0, int millisecond=0, int microsecond=0)
 Computes the Julian day for an UTC time.
static double toJulianDay (Timestamp::UtcTimeVal utcTime)
static Timestamp::UtcTimeVal toUtcTime (double julianDay)

Private Member Functions

void checkLimit (short &lower, short &higher, short limit)
 Extracts the daytime (hours, minutes, seconds, etc.) from the stored utcTime.
void normalize ()

Private Attributes

short _day
short _hour
short _microsecond
short _millisecond
short _minute
short _month
short _second
Timestamp::UtcTimeVal _utcTime
 utility functions used to correct the overflow in computeGregorian
short _year

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

Generated by  Doxygen 1.6.0   Back to index