PixelLightAPI  .
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes
PLCore::Time Class Reference

Time and date class. More...

#include <Time.h>

List of all members.

Public Types

enum  EMonth {
  January = 1, February, March, April,
  May, June, July, August,
  September, October, November, December
}
 Month of year enumeration. More...
enum  EDay {
  Sunday = 0, Monday, Tuesday, Wednesday,
  Thursday, Friday, Saturday
}
 Day of week enumeration. More...

Public Member Functions

PLCORE_API Time ()
 Constructor.
PLCORE_API Time (uint16 nYear, EMonth nMonth, uint8 nDayOfMonth, EDay nDayOfWeek, uint8 nHour, uint8 nMinute, uint8 nSecond, uint16 nMillisecond)
 Constructor.
 ~Time ()
 Destructor.
uint16 GetYear () const
 Get the year.
void SetYear (uint16 nYear)
 Set the year.
EMonth GetMonth () const
 Get the month.
void SetMonth (EMonth nMonth)
 Set the month.
uint8 GetDayOfMonth () const
 Get the day of the month.
void SetDayOfMonth (uint8 nDayOfMonth)
 Set the day of the month.
EDay GetDayOfWeek () const
 Get the day of the week.
void SetDayOfWeek (EDay nDayOfWeek)
 Set the day of the week.
uint8 GetHour () const
 Get the hour.
void SetHour (uint8 nHour)
 Set the hour.
uint8 GetMinute () const
 Get the minute.
void SetMinute (uint8 nMinute)
 Set the minute.
uint8 GetSecond () const
 Get the second.
void SetSecond (uint8 nSecond)
 Set the second.
uint16 GetMillisecond () const
 Get the millisecond.
void SetMillisecond (uint16 nMillisecond)
 Set the millisecond.
PLCORE_API String ToString () const
 Returns a string representation of the time.
PLCORE_API void FromString (const String &sString)
 Set time from string representation.
PLCORE_API void SetUnixDate (uint32 nUnixDate)
 Converts a date from Unix/POSIX format.
PLCORE_API void SetDOSDate (uint32 nDOSDate)
 Converts a date from DOS format.
PLCORE_API bool operator== (const Time &cTime) const
PLCORE_API bool operator!= (const Time &cTime) const

Static Public Member Functions

static PLCORE_API bool IsLeapYear (uint32 nYear)
 Returns whether or not the given year is a leap year.
static PLCORE_API uint8 GetDaysPerMonth (EMonth nMonth, uint32 nYear=0)
 Returns the number of days in a month.
static PLCORE_API EDay CalculateDayOfWeek (uint8 nDayOfMonth, EMonth nMonth, uint16 nYear)
 Calculates the day of a week.

Static Public Attributes

static PLCORE_API const Time Null
static PLCORE_API const Time UnixEpochStart
static PLCORE_API const Time DOSEpochStart
static PLCORE_API const String ShortMonthName [12]
static PLCORE_API const String ShortDayName [7]

Detailed Description

Time and date class.

Note:
  • If the year is between [1970..January 19, 2038] it's Unix/POSIX (32 bit) compatible
  • If the year is between [1980..January 1, 2108] it's DOS compatible

Member Enumeration Documentation

Month of year enumeration.

Enumerator:
January 

January

February 

February

March 

March

April 

April

May 

May

June 

June

July 

July

August 

August

September 

September

October 

October

November 

November

December 

December

Day of week enumeration.

Enumerator:
Sunday 

Sunday

Monday 

Monday

Tuesday 

Tuesday

Wednesday 

Wednesday

Thursday 

Thursday

Friday 

Friday

Saturday 

Saturday


Constructor & Destructor Documentation

PLCORE_API PLCore::Time::Time ( )
PLCORE_API PLCore::Time::Time ( uint16  nYear,
EMonth  nMonth,
uint8  nDayOfMonth,
EDay  nDayOfWeek,
uint8  nHour,
uint8  nMinute,
uint8  nSecond,
uint16  nMillisecond 
)

Constructor.

Parameters:
[in]nYearYear
[in]nMonthMonth [January..December]
[in]nDayOfMonthDay of the month [1..31]
[in]nDayOfWeekDay of the week [Sunday..Saturday]
[in]nHourHour [0..23]
[in]nMinuteMinute [0..59]
[in]nSecondSecond [0..59]
[in]nMillisecondMillisecond [0..999]
PLCore::Time::~Time ( ) [inline]

Destructor.


Member Function Documentation

static PLCORE_API bool PLCore::Time::IsLeapYear ( uint32  nYear) [static]

Returns whether or not the given year is a leap year.

Parameters:
[in]nYearYear to check
Returns:
'true' if the the given year is a leap year, else 'false'
static PLCORE_API uint8 PLCore::Time::GetDaysPerMonth ( EMonth  nMonth,
uint32  nYear = 0 
) [static]

Returns the number of days in a month.

Parameters:
[in]nMonthMonth to check
[in]nYearYear to check (0 == ignore, and assume no leap year)
Returns:
Number of days in the given month
static PLCORE_API EDay PLCore::Time::CalculateDayOfWeek ( uint8  nDayOfMonth,
EMonth  nMonth,
uint16  nYear 
) [static]

Calculates the day of a week.

Parameters:
[in]nDayOfMonthDay of month
[in]nMonthMonth
[in]nYearYear
Returns:
The day of a week
uint16 PLCore::Time::GetYear ( ) const [inline]

Get the year.

Returns:
Year
void PLCore::Time::SetYear ( uint16  nYear) [inline]

Set the year.

Parameters:
[in]nYearYear

Get the month.

Returns:
Month [January..December]
void PLCore::Time::SetMonth ( EMonth  nMonth) [inline]

Set the month.

Parameters:
[in]nMonthMonth [January..December]
uint8 PLCore::Time::GetDayOfMonth ( ) const [inline]

Get the day of the month.

Returns:
Day of the month [1..31]
void PLCore::Time::SetDayOfMonth ( uint8  nDayOfMonth) [inline]

Set the day of the month.

Parameters:
[in]nDayOfMonthDay of the month [1..31]

Get the day of the week.

Returns:
Day of the week [Sunday..Saturday]
void PLCore::Time::SetDayOfWeek ( EDay  nDayOfWeek) [inline]

Set the day of the week.

Parameters:
[in]nDayOfWeekDay of the week [Sunday..Saturday]
uint8 PLCore::Time::GetHour ( ) const [inline]

Get the hour.

Returns:
Hour [0..23]
void PLCore::Time::SetHour ( uint8  nHour) [inline]

Set the hour.

Parameters:
[in]nHourHour [0..23]
uint8 PLCore::Time::GetMinute ( ) const [inline]

Get the minute.

Returns:
Minute [0..59]
void PLCore::Time::SetMinute ( uint8  nMinute) [inline]

Set the minute.

Parameters:
[in]nMinuteMinute [0..59]
uint8 PLCore::Time::GetSecond ( ) const [inline]

Get the second.

Returns:
Second [0..59]
void PLCore::Time::SetSecond ( uint8  nSecond) [inline]

Set the second.

Parameters:
[in]nSecondSecond [0..59]
uint16 PLCore::Time::GetMillisecond ( ) const [inline]

Get the millisecond.

Returns:
Millisecond [0..999]
void PLCore::Time::SetMillisecond ( uint16  nMillisecond) [inline]

Set the millisecond.

Parameters:
[in]nMillisecondMillisecond [0..999]
PLCORE_API String PLCore::Time::ToString ( ) const

Returns a string representation of the time.

Returns:
String representation (for example: Sun Sep 16 01:03:52 1973)
PLCORE_API void PLCore::Time::FromString ( const String sString)

Set time from string representation.

Parameters:
[in]sStringString representation (for example: Sun Sep 16 01:03:52 1973)
PLCORE_API void PLCore::Time::SetUnixDate ( uint32  nUnixDate)

Converts a date from Unix/POSIX format.

Parameters:
[in]nUnixDateDate in Unix format
PLCORE_API void PLCore::Time::SetDOSDate ( uint32  nDOSDate)

Converts a date from DOS format.

Parameters:
[in]nDOSDateDate in DOS format
PLCORE_API bool PLCore::Time::operator== ( const Time cTime) const
PLCORE_API bool PLCore::Time::operator!= ( const Time cTime) const

Member Data Documentation

PLCORE_API const Time PLCore::Time::Null [static]

Year=0 Month=January Day=1 DayOfWeek=Sunday Hour=0 Minute=0 Second=0 Millisecond=0

PLCORE_API const Time PLCore::Time::UnixEpochStart [static]

Year=1970 Month=January Day=1 DayOfWeek=Thursday Hour=0 Minute=0 Second=0 Millisecond=0

PLCORE_API const Time PLCore::Time::DOSEpochStart [static]

Year=1980 Month=January Day=1 DayOfWeek=Tuesday Hour=0 Minute=0 Second=0 Millisecond=0

PLCORE_API const String PLCore::Time::ShortMonthName[12] [static]

Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec

PLCORE_API const String PLCore::Time::ShortDayName[7] [static]

Sun, Mon, Tue, Wed, Thu, Fri, Sat


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


PixelLight PixelLight 0.9.11-R1
Copyright (C) 2002-2012 by The PixelLight Team
Last modified Thu Feb 23 2012 14:09:29
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported