GDateTime Class Reference

#include <GDateTime.h>

List of all members.

Classes

struct  GDstInfo
 Daylight savings info record. More...

Public Types

enum  { Second64Bit = 1000 }

Public Member Functions

int Day ()
 Returns the day.
void Day (int d)
 Sets the day.
int Month ()
 Returns the month.
void Month (int m)
 Sets the month.
void Month (char *m)
 Sets the month by it's name.
int Year ()
 Returns the year.
void Year (int y)
 Sets the year.
int Thousands ()
 Returns the millisecond part of the time.
void Thousands (int t)
 Sets the millisecond part of the time.
int Seconds ()
 Returns the seconds part of the time.
void Seconds (int s)
 Sets the seconds part of the time.
int Minutes ()
 Returns the minutes part of the time.
void Minutes (int m)
 Sets the minutes part of the time.
int Hours ()
 Returns the hours part of the time.
void Hours (int h)
 Sets the hours part of the time.
int GetTimeZone ()
 Returns the timezone of this current date time object in minutes (+10 = 600).
void SetTimeZone (int Tz, bool ConvertTime)
 Sets the timezone of this current object.in minutes (+10 = 600).
void ToUtc ()
void ToLocal ()
uchar GetFormat ()
void SetFormat (uchar f)
int DayOfWeek ()
 Returns the day of the week as an index, 0=sun, 1=mon, 2=teus etc.
void Get (char *Str)
bool Get (uint64 &s)
 Gets the data and time as a 64 bit int (os specific).
void GetDate (char *Str)
void GetTime (char *Str)
void SetNow ()
 Sets the date and time to the system clock.
bool Set (char *Str)
bool Set (uint64 s)
 Sets the date and time from a 64 bit int (os specific).
bool Set (time_t tt)
 Sets the time from a time_t.
bool SetDate (char *Str)
bool SetTime (char *Str)
bool IsLeapYear (int Year=-1)
bool IsSameDay (GDateTime &d)
int DaysInMonth ()
void AddSeconds (int64 Seconds)
 Adds a number of seconds to the current date/time.
void AddMinutes (int Minutes)
 Adds a number of minutes to the current date/time.
void AddHours (int Hours)
 Adds a number of hours to the current date/time.
void AddDays (int Days)
 Adds a number of days to the current date/time.
void AddMonths (int Months)
 Adds a number of months to the current date/time.
GDateTime operator- (GDateTime &dt)

Static Public Member Functions

static uchar GetDefaultFormat ()
 The default format for the date when formatted as a string.
static void SetDefaultFormat (uchar f)
 Sets the default format for the date when formatted as a string.
static int SystemTimeZone (bool ForceUpdate=false)
 The system timezone including daylight savings offset in minutes, +10 would return 600.
static int SystemTimeZoneOffset ()
static bool GetDaylightSavingsInfo (GArray< GDstInfo > &Out, GDateTime &Start, GDateTime *End=0)


Detailed Description

A date/time class

This class interacts with system times represented as 64bit ints. The various OS support different formats for that 64bit int values. On windows the system times are in 100-nanosecond intervals since January 1, 1601 (UTC), as per the FILETIME structure, on Posix systems (Linux/Mac) the 64bit values are in milliseconds since January 1, 1970 UTC. This is just unix time * 1000. If you are serializing these 64bit values you should take that into account, they are NOT cross platform. The GDirectory class uses the same 64bit values as accepted here for the file's last modified timestamp etc. To convert the 64bit values to seconds, divide by GDateTime::Second64Bit, useful for calculating the time in seconds between 2 GDateTime objects.


Member Enumeration Documentation

anonymous enum

Enumerator:
Second64Bit  Resolution of a second when using 64 bit int's
See also:
GDateTime::Get(int64), GDateTime::Set(int64)


Member Function Documentation

int GDateTime::DaysInMonth (  ) 

Returns:
the number of days in the current month

References IsLeapYear().

Referenced by AddDays().

void GDateTime::Get ( char *  Str  ) 

Gets the date and time as a string

See also:
GDateTime::GetFormat()

References GetDate(), and GetTime().

Referenced by operator-().

void GDateTime::GetDate ( char *  Str  ) 

Gets just the date as a string

See also:
GDateTime::GetFormat()

References GDTF_DAY_MONTH_YEAR, GDTF_MONTH_DAY_YEAR, and GDTF_YEAR_MONTH_DAY.

Referenced by Get().

bool GDateTime::GetDaylightSavingsInfo ( GArray< GDstInfo > &  Out,
GDateTime Start,
GDateTime End = 0 
) [static]

Retreives daylight savings start and end events for a given period. One event will be emitted for the current DST/TZ setting at the datetime specified by 'Start', followed by any changes that occur between that and the 'End' datetime. To retreive just the DST info for start, use NULL for end.

Parameters:
Out  [Out] The array to receive DST info. At minimum one record will be returned matching the TZ in place for the start datetime.
Start  [In] The start date that you want DST info for.
End  [Optional In] The end of the period you want DST info for.

References GHashTbl< Key, Value >::Add(), GArray< Type >::Add(), Day(), GHashTbl< Key, Value >::Find(), Hours(), GArray< Type >::Length(), Minutes(), Month(), GArray< Type >::New(), GStringPipe::NewStr(), GDateTime::GDstInfo::Offset, Seconds(), SetTimeZone(), GArray< Type >::Sort(), GDateTime::GDstInfo::UtcTimeStamp, GBytePipe::Write(), and Year().

uchar GDateTime::GetFormat (  )  [inline]

Gets the current formatting of the date, the format only effects the representation of the date when converted to/from a string.

Returns:
a bit mask of (GDTF_DAY_MONTH_YEAR or GDTF_MONTH_DAY_YEAR or GDTF_YEAR_MONTH_DAY) and (GDTF_12HOUR or GDTF_24HOUR)

void GDateTime::GetTime ( char *  Str  ) 

Gets just the time as a string

See also:
GDateTime::GetFormat()

References GDTF_12HOUR, and GDTF_24HOUR.

Referenced by Get().

bool GDateTime::IsLeapYear ( int  Year = -1  ) 

Returns:
whether a year is a leap year or not
Parameters:
Year  Pass a specific year here, or ignore to return if the current Date/Time is in a leap year.

Referenced by DayOfWeek(), and DaysInMonth().

bool GDateTime::IsSameDay ( GDateTime d  ) 

Returns:
true if 'd' is on the same day as this object

References Day(), Month(), and Year().

GDateTime GDateTime::operator- ( GDateTime dt  ) 

Resolution of a second when using 64 bit timestamps

References _Day, _Hours, _Minutes, _Seconds, _Thousands, Day(), Get(), and Second64Bit.

bool GDateTime::Set ( char *  Str  ) 

bool GDateTime::SetDate ( char *  Str  ) 

Parses the date from a string

See also:
GDateTime::GetFormat()

References GDTF_DAY_MONTH_YEAR, GDTF_MONTH_DAY_YEAR, GDTF_YEAR_MONTH_DAY, and GArray< Type >::Length().

Referenced by Set().

void GDateTime::SetFormat ( uchar  f  )  [inline]

Sets the current formatting of the date, the format only effects the representation of the date when converted to/from a string

Parameters:
f  a bit mask of (GDTF_DAY_MONTH_YEAR or GDTF_MONTH_DAY_YEAR or GDTF_YEAR_MONTH_DAY) and (GDTF_12HOUR or GDTF_24HOUR)

bool GDateTime::SetTime ( char *  Str  ) 

Parses the time from a string

See also:
GDateTime::GetFormat()

References GArray< Type >::Length().

Referenced by Set().

void GDateTime::SetTimeZone ( int  Tz,
bool  ConvertTime 
)

Sets the timezone of this current object.in minutes (+10 = 600).

Parameters:
Tz  The new timezone
ConvertTime  True if you want to convert the date and time to the new zone, False if you want to leave the date/time as it is.

References AddMinutes().

Referenced by GetDaylightSavingsInfo().

int GDateTime::SystemTimeZoneOffset (  )  [static]

Any daylight savings offset applied to TimeZone(), in minutes. e.g. to retreive the timezone uneffected by DST use TimeZone() - TimeZoneOffset().

References SystemTimeZone().

void GDateTime::ToLocal (  )  [inline]

Changes the timezone to the local zone, changing other members as needed.

void GDateTime::ToUtc (  )  [inline]

Set this object to UTC timezone, changing the other members as needed


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

Generated on Wed Dec 1 15:41:02 2010 for Lgi by  doxygen 1.5.7.1