#include <ptime.h>
Inheritance diagram for PTime:
Construction | |
enum | { UTC = 0, GMT = UTC, Local = 9999 } |
PTime () | |
PTime (time_t tsecs, long usecs=0) | |
PTime (const PString &str) | |
PTime (int second, int minute, int hour, int day, int month, int year, int tz=Local) | |
Access functions | |
enum | Months { January = 1, February, March, April, May, June, July, August, September, October, November, December } |
Month codes. More... | |
enum | Weekdays { Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday } |
Days of the week. More... | |
BOOL | IsValid () const |
PInt64 | GetTimestamp () const |
time_t | GetTimeInSeconds () const |
long | GetMicrosecond () const |
int | GetSecond () const |
int | GetMinute () const |
int | GetHour () const |
int | GetDay () const |
Months | GetMonth () const |
int | GetYear () const |
Weekdays | GetDayOfWeek () const |
int | GetDayOfYear () const |
BOOL | IsPast () const |
BOOL | IsFuture () const |
Time Zone configuration functions | |
enum | TimeZoneType { StandardTime, DaylightSavings } |
Flag for time zone adjustment on daylight savings. More... | |
BOOL | IsDaylightSavings () |
int | GetTimeZone () |
Get the time zone offset in minutes. | |
int | GetTimeZone (TimeZoneType type) |
PString | GetTimeZoneString (TimeZoneType type=StandardTime) |
String conversion functions | |
enum | TimeFormat { RFC1123, ShortISO8601, LongISO8601, LongDateTime, LongDate, LongTime, MediumDateTime, MediumDate, ShortDateTime, ShortDate, ShortTime, NumTimeStrings } |
Standard time formats for string representations of a time and date. More... | |
PString | AsString (TimeFormat formatCode=RFC1123, int zone=Local) const |
PString | AsString (const PString &formatStr, int zone=Local) const |
PString | AsString (const char *formatPtr, int zone=Local) const |
Internationalisation functions | |
enum | NameType { FullName, Abbreviated } |
Flag for returning language dependent string names. More... | |
enum | DateOrder { MonthDayYear, DayMonthYear, YearMonthDay } |
Possible orders for date components. More... | |
PString | GetTimeSeparator () |
BOOL | GetTimeAMPM () |
PString | GetTimeAM () |
PString | GetTimePM () |
PString | GetDayName (Weekdays dayOfWeek, NameType type=FullName) |
PString | GetDateSeparator () |
PString | GetMonthName (Months month, NameType type=FullName) |
DateOrder | GetDateOrder () |
Public Types | |
Public Member Functions | |
Overrides from class PObject | |
PObject * | Clone () const |
virtual Comparison | Compare (const PObject &obj) const |
virtual void | PrintOn (ostream &strm) const |
virtual void | ReadFrom (istream &strm) |
Operations | |
PTime | operator+ (const PTimeInterval &time) const |
PTime & | operator+= (const PTimeInterval &time) |
PTimeInterval | operator- (const PTime &time) const |
PTime | operator- (const PTimeInterval &time) const |
PTime & | operator-= (const PTimeInterval &time) |
Static Public Member Functions | |
tm * | os_localtime (const time_t *clock, struct tm *t) |
tm * | os_gmtime (const time_t *clock, struct tm *t) |
Protected Attributes | |
time_t | theTime |
Number of seconds since 1 January 1970. | |
long | microseconds |
|
Time Zone special codes. The value for a time zone is usually in minutes from UTC, this enum are special values for specific areas. |
|
Possible orders for date components.
|
|
Month codes.
|
|
Flag for returning language dependent string names.
|
|
|
Flag for time zone adjustment on daylight savings.
|
|
Days of the week.
|
|
Create a time object instance. This initialises the time with the current time in the current time zone. |
|
Create a time object instance. This initialises the time to the specified time.
|
|
Create a time object instance. This initialises the time to the specified time, parsed from the string. The string may be in many different formats, for example: "5/03/1999 12:34:56" "15/06/1999 12:34:56" "15/06/01 12:34:56 PST" "5/06/02 12:34:56" "5/23/1999 12:34am" "5/23/00 12:34am" "1999/23/04 12:34:56" "Mar 3, 1999 12:34pm" "3 Jul 2004 12:34pm" "12:34:56 5 December 1999" "10 minutes ago" "2 weeks"
|
|
Create a time object instance. This initialises the time to the specified time.
|
|
|
|
Convert the time to a string representation.
|
|
Convert the time to a string representation.
|
|
Create a copy of the time on the heap. It is the responsibility of the caller to delete the created object.
Reimplemented from PObject. |
|
Determine the relative rank of the specified times. This ranks the times as you would expect.
Reimplemented from PObject. |
|
Return the internationalised date order.
|
|
Get the internationalised date separator.
|
|
Get the day of the month of the date.
|
|
Get the internationalised day of week day name (0=Sun etc).
|
|
Get the day of the week of the date.
|
|
Get the day in the year of the date.
|
|
Get the hour of the time.
|
|
Get the microsecond part of the time.
|
|
Get the minute of the time.
|
|
Get the month of the date.
|
|
Get the internationalised month name string (1=Jan etc).
|
|
Get the second of the time.
|
|
Get the internationalised time AM string.
|
|
Get the internationalised time format: AM/PM or 24 hour.
|
|
Get the total seconds since the epoch. The epoch is the 1st January 1970.
|
|
Get the internationalised time PM string.
|
|
Get the internationalised time separator.
|
|
Get the total microseconds since the epoch. The epoch is the 1st January 1970.
|
|
Get the time zone offset in minutes. This is the number of minutes to add to UTC (previously known as GMT) to get the local time. The first form automatically adjusts for daylight savings time, whilst the second form returns the specified time.
|
|
Get the time zone offset in minutes.
|
|
Get the text identifier for the local time zone .
|
|
Get the year of the date.
|
|
Get flag indicating daylight savings is current.
|
|
Determine if the time is in the past or in the future.
|
|
Determine if the time is in the past or in the future.
|
|
Determine if the timestamp is valid. This will return TRUE if the timestamp can be represented as a time in the epoch. The epoch is the 1st January 1970. In practice this means the time is > 13 hours to allow for time zones. |
|
Add the interval to the time to yield a new time.
|
|
Add the interval to the time changing the instance.
|
|
Subtract the interval from the time to yield a new time.
|
|
Calculate the difference between two times to get a time interval.
|
|
Subtract the interval from the time changing the instance.
|
|
|
|
|
|
Output the time to the stream. This uses the #AsString()# function with the ShortDateTime# parameter.
Reimplemented from PObject. |
|
Input the time from the specified stream. If a parse error occurs the time is set to the current time. The string may be in many different formats, for example: "5/03/1999 12:34:56" "15/06/1999 12:34:56" "15/06/01 12:34:56 PST" "5/06/02 12:34:56" "5/23/1999 12:34am" "5/23/00 12:34am" "1999/23/04 12:34:56" "Mar 3, 1999 12:34pm" "3 Jul 2004 12:34pm" "12:34:56 5 December 1999" "10 minutes ago" "2 weeks"
Reimplemented from PObject. |
|
|
|
Number of seconds since 1 January 1970.
|