#include <GDateTime.h>
Public Types | |
enum | { Second64Bit = 1000 } |
Public Member Functions | |
bool | IsValid () |
Returns true if all the components are in a valid range. | |
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 () |
uint16 | GetFormat () |
void | SetFormat (uint16 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 (const 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 (const char *Str) |
bool | SetTime (const 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 uint16 | GetDefaultFormat () |
The default format for the date when formatted as a string. | |
static void | SetDefaultFormat (uint16 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) |
Classes | |
struct | GDstInfo |
Daylight savings info record. More... |
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.
anonymous enum |
void GDateTime::SetTimeZone | ( | int | Tz, | |
bool | ConvertTime | |||
) |
Sets the timezone of this current object.in minutes (+10 = 600).
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().
void GDateTime::ToUtc | ( | ) | [inline] |
Set this object to UTC timezone, changing the other members as needed
void GDateTime::ToLocal | ( | ) | [inline] |
Changes the timezone to the local zone, changing other members as needed.
uint16 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.
void GDateTime::SetFormat | ( | uint16 | f | ) | [inline] |
Sets the current formatting of the date, the format only effects the representation of the date when converted to/from a string
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) |
void GDateTime::Get | ( | char * | Str | ) |
Gets the date and time as a string
References GetDate(), and GetTime().
Referenced by operator-().
void GDateTime::GetDate | ( | char * | Str | ) |
Gets just the date as a string
References GDTF_DAY_LEADINGZ, GDTF_DAY_MONTH_YEAR, GDTF_MONTH_DAY_YEAR, GDTF_MONTH_LEADINGZ, and GDTF_YEAR_MONTH_DAY.
Referenced by Get().
void GDateTime::GetTime | ( | char * | Str | ) |
Gets just the time as a string
References GDTF_12HOUR, and GDTF_24HOUR.
Referenced by Get().
bool GDateTime::Set | ( | const char * | Str | ) |
Parses a date time from a string
References SetDate(), and SetTime().
Referenced by GVariant::Cast(), GTimePopup::OnMouseClick(), GDatePopup::OnMouseClick(), GTarParser::Parse(), Set(), and SetNow().
bool GDateTime::SetDate | ( | const char * | Str | ) |
Parses the date from a string
References GDTF_DAY_MONTH_YEAR, GDTF_MONTH_DAY_YEAR, GDTF_YEAR_MONTH_DAY, and GArray< Type >::Length().
Referenced by Set().
bool GDateTime::SetTime | ( | const char * | Str | ) |
Parses the time from a string
References GArray< Type >::Length().
Referenced by Set().
bool GDateTime::IsLeapYear | ( | int | Year = -1 |
) |
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 | ) |
int GDateTime::DaysInMonth | ( | ) |
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().
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.
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().
Resolution of a second when using 64 bit timestamps
References _Day, _Hours, _Minutes, _Seconds, _Thousands, Day(), Get(), and Second64Bit.