Ark Server API (ASE) - Wiki
|
#include <DateTime.h>
Public Types | |
enum | Months { JANUARY = 1 , FEBRUARY , MARCH , APRIL , MAY , JUNE , JULY , AUGUST , SEPTEMBER , OCTOBER , NOVEMBER , DECEMBER } |
Symbolic names for month numbers (1 to 12). More... | |
enum | DaysOfWeek { SUNDAY = 0 , MONDAY , TUESDAY , WEDNESDAY , THURSDAY , FRIDAY , SATURDAY } |
Symbolic names for week day numbers (0 to 6). More... | |
Public Member Functions | |
DateTime () | |
DateTime (const tm &tmStruct) | |
Creates a DateTime for the current date and time. | |
DateTime (const Timestamp ×tamp) | |
Creates a DateTime from tm struct. | |
DateTime (int year, int month, int day, int hour=0, int minute=0, int second=0, int millisecond=0, int microsecond=0) | |
DateTime (double julianDay) | |
DateTime (Timestamp::UtcTimeVal utcTime, Timestamp::TimeDiff diff) | |
Creates a DateTime for the given Julian day. | |
DateTime (const DateTime &dateTime) | |
~DateTime () | |
Copy constructor. Creates the DateTime from another one. | |
DateTime & | operator= (const DateTime &dateTime) |
Destroys the DateTime. | |
DateTime & | operator= (const Timestamp ×tamp) |
Assigns another DateTime. | |
DateTime & | operator= (double julianDay) |
Assigns a Timestamp. | |
DateTime & | assign (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. | |
void | swap (DateTime &dateTime) |
int | year () const |
Swaps the DateTime with another one. | |
int | month () const |
Returns the year. | |
int | week (int firstDayOfWeek=MONDAY) const |
Returns the month (1 to 12). | |
int | day () const |
int | dayOfWeek () const |
Returns the day within 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;. | |
int | minute () const |
Returns true if hour >= 12. | |
int | second () const |
Returns the minute (0 to 59). | |
int | millisecond () const |
Returns the second (0 to 59). | |
int | microsecond () const |
Returns the millisecond (0 to 999) | |
double | julianDay () const |
Returns the microsecond (0 to 999) | |
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. | |
bool | operator== (const DateTime &dateTime) const |
bool | operator!= (const DateTime &dateTime) const |
bool | operator< (const DateTime &dateTime) const |
bool | operator<= (const DateTime &dateTime) const |
bool | operator> (const DateTime &dateTime) const |
bool | operator>= (const DateTime &dateTime) const |
DateTime | operator+ (const Timespan &span) const |
DateTime | operator- (const Timespan &span) const |
Timespan | operator- (const DateTime &dateTime) const |
DateTime & | operator+= (const Timespan &span) |
DateTime & | operator-= (const Timespan &span) |
tm | makeTM () const |
void | makeUTC (int tzd) |
Converts DateTime to tm struct. | |
void | makeLocal (int tzd) |
Converts a local time into UTC, by applying the given time zone differential. | |
Static Public Member Functions | |
static bool | isLeapYear (int year) |
Converts a UTC time into a local time, by applying the given time zone differential. | |
static int | daysOfMonth (int year, int month) |
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 | computeGregorian (double julianDay) |
Computes the UTC time for a Julian day. | |
void | computeDaytime () |
Static Protected Member Functions | |
static double | toJulianDay (Timestamp::UtcTimeVal utcTime) |
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 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 | |
Timestamp::UtcTimeVal | _utcTime |
utility functions used to correct the overflow in computeGregorian | |
short | _year |
short | _month |
short | _day |
short | _hour |
short | _minute |
short | _second |
short | _millisecond |
short | _microsecond |
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.
The date and time stored in a DateTime is always in UTC (Coordinated Universal Time) and thus independent of the timezone in effect on the system.
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:
For more information, please see:
Definition at line 32 of file DateTime.h.
Symbolic names for week day numbers (0 to 6).
Enumerator | |
---|---|
SUNDAY | |
MONDAY | |
TUESDAY | |
WEDNESDAY | |
THURSDAY | |
FRIDAY | |
SATURDAY |
Definition at line 81 of file DateTime.h.
Symbolic names for month numbers (1 to 12).
Enumerator | |
---|---|
JANUARY | |
FEBRUARY | |
MARCH | |
APRIL | |
MAY | |
JUNE | |
JULY | |
AUGUST | |
SEPTEMBER | |
OCTOBER | |
NOVEMBER | |
DECEMBER |
Definition at line 64 of file DateTime.h.
Poco::DateTime::DateTime | ( | ) |
Poco::DateTime::DateTime | ( | const tm & | tmStruct | ) |
Creates a DateTime for the current date and time.
Poco::DateTime::DateTime | ( | int | year, |
int | month, | ||
int | day, | ||
int | hour = 0, | ||
int | minute = 0, | ||
int | second = 0, | ||
int | millisecond = 0, | ||
int | microsecond = 0 ) |
Poco::DateTime::DateTime | ( | double | julianDay | ) |
Creates a DateTime for the given Gregorian date and time.
Throws an InvalidArgumentException if an argument date is out of range.
Poco::DateTime::DateTime | ( | Timestamp::UtcTimeVal | utcTime, |
Timestamp::TimeDiff | diff ) |
Creates a DateTime for the given Julian day.
Poco::DateTime::DateTime | ( | const DateTime & | dateTime | ) |
Poco::DateTime::~DateTime | ( | ) |
Copy constructor. Creates the DateTime from another one.
DateTime & Poco::DateTime::assign | ( | 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.
|
private |
Extracts the daytime (hours, minutes, seconds, etc.) from the stored utcTime.
|
protected |
Computes the Gregorian date for the given Julian day. See http://vsg.cape.com/~pbaum/date/injdimp.htm, section 3.3.1 for the algorithm.
|
protected |
Computes the UTC time for a Julian day.
|
inline |
Returns the week number within the year. FirstDayOfWeek should be either SUNDAY (0) or MONDAY (1). The returned week number will be from 0 to 53. Week number 1 is the week containing January 4. This is in accordance to ISO 8601.
The following example assumes that firstDayOfWeek is MONDAY. For 2005, which started on a Saturday, week 1 will be the week starting on Monday, January 3. January 1 and 2 will fall within week 0 (or the last week of the previous year).
For 2007, which starts on a Monday, week 1 will be the week starting on Monday, January 1. There will be no week 0 in 2007.
Definition at line 333 of file DateTime.h.
int Poco::DateTime::dayOfWeek | ( | ) | const |
Returns the day within the month (1 to 31).
int Poco::DateTime::dayOfYear | ( | ) | const |
Returns the weekday (0 to 6, where 0 = Sunday, 1 = Monday, ..., 6 = Saturday).
|
static |
Returns true if the given year is a leap year; false otherwise.
|
inline |
Returns the number of the day in the year. January 1 is 1, February 1 is 32, etc.
Definition at line 339 of file DateTime.h.
|
inline |
Returns the hour (0 to 23).
Definition at line 345 of file DateTime.h.
|
inline |
Returns the hour (0 to 12).
Definition at line 356 of file DateTime.h.
|
inlinestatic |
Converts a UTC time into a local time, by applying the given time zone differential.
Definition at line 428 of file DateTime.h.
|
inline |
Returns true if hour < 12;.
Definition at line 362 of file DateTime.h.
|
static |
Returns the number of days in the given month and year. Month is from 1 to 12.
double Poco::DateTime::julianDay | ( | ) | const |
Returns the microsecond (0 to 999)
void Poco::DateTime::makeLocal | ( | int | tzd | ) |
Converts a local time into UTC, by applying the given time zone differential.
tm Poco::DateTime::makeTM | ( | ) | const |
void Poco::DateTime::makeUTC | ( | int | tzd | ) |
Converts DateTime to tm struct.
|
inline |
Returns the millisecond (0 to 999)
Definition at line 386 of file DateTime.h.
|
inline |
Returns the second (0 to 59).
Definition at line 380 of file DateTime.h.
|
inline |
Returns true if hour >= 12.
Definition at line 368 of file DateTime.h.
|
inline |
Returns the year.
Definition at line 327 of file DateTime.h.
|
private |
|
inline |
Definition at line 398 of file DateTime.h.
|
inline |
Definition at line 404 of file DateTime.h.
|
inline |
Definition at line 410 of file DateTime.h.
|
inline |
Returns the date and time expressed in UTC-based time. UTC base time is midnight, October 15, 1582. Resolution is 100 nanoseconds.
Definition at line 392 of file DateTime.h.
|
inline |
Definition at line 416 of file DateTime.h.
|
inline |
Definition at line 422 of file DateTime.h.
|
inline |
Returns the minute (0 to 59).
Definition at line 374 of file DateTime.h.
void Poco::DateTime::swap | ( | DateTime & | dateTime | ) |
Assigns a Gregorian date and time.
Throws an InvalidArgumentException if an argument date is out of range.
|
inline |
Returns the julian day for the date and time.
Definition at line 309 of file DateTime.h.
|
staticprotected |
Computes the Julian day for an UTC time.
|
inlinestaticprotected |
Checks if the given date and time is valid (all arguments are within a proper range).
Returns true if all arguments are valid, false otherwise.
Definition at line 296 of file DateTime.h.
|
inlinestaticprotected |
Computes the Julian day for a Gregorian calendar date and time. See http://vsg.cape.com/~pbaum/date/jdimp.htm, section 2.3.1 for the algorithm.
Definition at line 303 of file DateTime.h.
|
inline |
Returns the date and time expressed as a Timestamp.
Definition at line 315 of file DateTime.h.
int Poco::DateTime::week | ( | int | firstDayOfWeek = MONDAY | ) | const |
Returns the month (1 to 12).
|
inline |
Swaps the DateTime with another one.
Definition at line 321 of file DateTime.h.
|
private |
Definition at line 282 of file DateTime.h.
|
private |
Definition at line 283 of file DateTime.h.
|
private |
Definition at line 287 of file DateTime.h.
|
private |
Definition at line 286 of file DateTime.h.
|
private |
Definition at line 284 of file DateTime.h.
|
private |
Definition at line 281 of file DateTime.h.
|
private |
Definition at line 285 of file DateTime.h.
|
private |
utility functions used to correct the overflow in computeGregorian
Definition at line 279 of file DateTime.h.
|
private |
Definition at line 280 of file DateTime.h.