class PTime: public PObject

This class defines an absolute time and date.

Inheritance:


Public

[more] Construction
[more] Overrides from class PObject
[more] Access functions
[more] Time Zone configuration functions
[more] Operations
[more] String conversion functions
[more] Internationalisation functions

Protected Fields

[more]time_t theTime
Number of seconds since 1 January 1970.


Inherited from PObject:

Public

Run Time Type functions

Comparison functions

I/O functions

Miscellaneous functions


Documentation

This class defines an absolute time and date. It has a number of time and date rendering and manipulation functions. It is based on the standard C library functions for time. Thus it is based on a number of seconds since 1 January 1970.
o Construction

o Time Zone special codes.
Time Zone special codes. The value for a time zone is usually in minutes from UTC, this enum are special values for specific areas.

o UTC
Universal Coordinated Time.

o GMT
Greenwich Mean Time, effectively UTC.

o Local
Local Time.

o PTime()
Create a time object instance. This initialises the time with the current time in the current time zone.

o PTime( time_t tsecs, long usecs = 0 )
Create a time object instance. This initialises the time to the specified time.
Parameters:
tsecs - Time in seconds since 00:00:00 1/1/70 UTC

o PTime( const PString & str )
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"
Parameters:
str - Time and data as a string

o PTime( int second, int minute, int hour, int day, int month, int year, int tz = Local )
Create a time object instance. This initialises the time to the specified time.
Parameters:
second - Second from 0 to 59.
minute - Minute from 0 to 59.
hour - Hour from 0 to 23.
day - Day of month from 1 to 31.
month - Month from 1 to 12.
year - Year from 1970 to 2038
tz - local time or UTC

o Overrides from class PObject

oPObject* Clone() const
Create a copy of the time on the heap. It is the responsibility of the caller to delete the created object.

Returns:
pointer to new time.

ovirtual Comparison Compare( const PObject & obj ) const
Determine the relative rank of the specified times. This ranks the times as you would expect.

Returns:
rank of the two times.
Parameters:
obj - Other time to compare against.

ovirtual void PrintOn( ostream & strm ) const
Output the time to the stream. This uses the AsString() function with the ShortDateTime parameter.
Parameters:
strm - Stream to output the time to.

ovirtual void ReadFrom( istream & strm )
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"
Parameters:
strm - Stream to input the time from.

o Access functions

oPInt64 GetTimestamp() const
Get the total microseconds since the epoch. The epoch is the 1st January 1970.

Returns:
microseconds.

otime_t GetTimeInSeconds() const
Get the total seconds since the epoch. The epoch is the 1st January 1970.

Returns:
seconds.

olong GetMicrosecond() const
Get the microsecond part of the time.

Returns:
integer in range 0..999999.

oint GetSecond() const
Get the second of the time.

Returns:
integer in range 0..59.

oint GetMinute() const
Get the minute of the time.

Returns:
integer in range 0..59.

oint GetHour() const
Get the hour of the time.

Returns:
integer in range 0..23.

oint GetDay() const
Get the day of the month of the date.

Returns:
integer in range 1..31.

oenum Months
Month codes.

oMonths GetMonth() const
Get the month of the date.

Returns:
enum for month.

oint GetYear() const
Get the year of the date.

Returns:
integer in range 1970..2038.

oenum Weekdays
Days of the week.

oWeekdays GetDayOfWeek() const
Get the day of the week of the date.

Returns:
enum for week days with 0=Sun, 1=Mon, ..., 6=Sat.

oint GetDayOfYear() const
Get the day in the year of the date.

Returns:
integer from 1..366.

oBOOL IsPast() const
Determine if the time is in the past or in the future.

Returns:
TRUE if time is before the current real time.

oBOOL IsFuture() const
Determine if the time is in the past or in the future.

Returns:
TRUE if time is after the current real time.

o Time Zone configuration functions

ostatic BOOL IsDaylightSavings()
Get flag indicating daylight savings is current.

Returns:
TRUE if daylight savings time is active.

oenum TimeZoneType
Flag for time zone adjustment on daylight savings.

ostatic int GetTimeZone()
Get the time zone offset in minutes.

ostatic int GetTimeZone( TimeZoneType type )
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.

Returns:
Number of minutes.
Parameters:
type - Daylight saving or standard time.

ostatic PString GetTimeZoneString( TimeZoneType type = StandardTime )
Get the text identifier for the local time zone .

Returns:
Time zone identifier string.
Parameters:
type - Daylight saving or standard time.

o Operations

oPTime operator+( const PTimeInterval & time ) const
Add the interval to the time to yield a new time.

Returns:
Time altered by the interval.
Parameters:
time - Time interval to add to the time.

oPTime& operator+=( const PTimeInterval & time )
Add the interval to the time changing the instance.

Returns:
reference to the current time instance.
Parameters:
time - Time interval to add to the time.

oPTimeInterval operator-( const PTime & time ) const
Calculate the difference between two times to get a time interval.

Returns:
Time intervale difference between the times.
Parameters:
time - Time to subtract from the time.

oPTime operator-( const PTimeInterval & time ) const
Subtract the interval from the time to yield a new time.

Returns:
Time altered by the interval.
Parameters:
time - Time interval to subtract from the time.

oPTime& operator-=( const PTimeInterval & time )
Subtract the interval from the time changing the instance.

Returns:
reference to the current time instance.
Parameters:
time - Time interval to subtract from the time.

o String conversion functions

oenum TimeFormat
Standard time formats for string representations of a time and date.

o RFC1123
Internet standard format.

o LongDateTime
Date with weekday, full month names and time with seconds.

o LongDate
Date with weekday, full month names and no time.

o LongTime
Time with seconds.

o MediumDateTime
Date with abbreviated month names and time without seconds.

o MediumDate
Date with abbreviated month names and no time.

o ShortDateTime
Date with numeric month name and time without seconds.

o ShortDate
Date with numeric month and no time.

o ShortTime
Time without seconds.

oPString AsString( TimeFormat formatCode = RFC1123, int zone = Local ) const
Convert the time to a string representation.
Parameters:
formatCode - Standard format for time.
zone - Time zone for the time.

oPString AsString( const PString & formatStr, int zone = Local ) const
Convert the time to a string representation.
Parameters:
formatStr - Arbitrary format string for time.
zone - Time zone for the time.

o Internationalisation functions

ostatic PString GetTimeSeparator()
Get the internationalised time separator.

Returns:
string for time separator.

ostatic BOOL GetTimeAMPM()
Get the internationalised time format: AM/PM or 24 hour.

Returns:
TRUE is 12 hour, FALSE if 24 hour.

ostatic PString GetTimeAM()
Get the internationalised time AM string.

Returns:
string for AM.

ostatic PString GetTimePM()
Get the internationalised time PM string.

Returns:
string for PM.

oenum NameType
Flag for returning language dependent string names.

ostatic PString GetDayName( Weekdays dayOfWeek, NameType type = FullName )
Get the internationalised day of week day name (0=Sun etc).

Returns:
string for week day.
Parameters:
dayOfWeek - Code for day of week.
type - Flag for abbreviated or full name.

ostatic PString GetDateSeparator()
Get the internationalised date separator.

Returns:
string for date separator.

ostatic PString GetMonthName( Months month, NameType type = FullName )
Get the internationalised month name string (1=Jan etc).

Returns:
string for month.
Parameters:
month - Code for month in year.
type - Flag for abbreviated or full name.

oenum DateOrder
Possible orders for date components.

ostatic DateOrder GetDateOrder()
Return the internationalised date order.

Returns:
code for date ordering.

otime_t theTime
Number of seconds since 1 January 1970.


This class has no child classes.

Alphabetic index HTML hierarchy of classes or Java



This page was generated with the help of DOC++.