datetime.h
Estructura wxDateTime::Tm
struct WXDLLIMPEXP_BASE Tm
{
wxDateTime_t msec, sec, min, hour,
mday, // Day of the month in 1..31 range.
yday; // Day of the year in 0..365 range.
Month mon;
int year;
// default ctor inits the object to an invalid value
Tm();
// ctor from struct tm and the timezone
Tm(const struct tm& tm, const TimeZone& tz);
// check that the given date/time is valid (in Gregorian calendar)
bool IsValid() const;
// get the week day
WeekDay GetWeekDay() // not const because wday may be changed
{
if ( wday == Inv_WeekDay )
ComputeWeekDay();
return (WeekDay)wday;
}
// add the given number of months to the date keeping it normalized
void AddMonths(int monDiff);
// add the given number of months to the date keeping it normalized
void AddDays(int dayDiff);
private:
// compute the weekday from other fields
void ComputeWeekDay();
// the timezone we correspond to
TimeZone m_tz;
// This value can only be accessed via GetWeekDay() and not directly
// because it's not always computed when creating this object and may
// need to be calculated on demand.
wxDateTime_t wday;
};
Contiene una representación desglosada de la fecha y la hora.
Esta estructura es análoga a la estructura tm estándar de C y utiliza las mismas convenciones, no siempre obvias, para sus miembros: en particular, sus campos mon y yday cuentan a partir de 0, mientras que mday cuenta a partir de 1.
Atributos públicos
- wxDateTime_t wxDateTime::Tm::hour
- Horas desde medianoche en el rango 0..23.
- wxDateTime_t wxDateTime::Tm::mday
- Día del mes en el rango 1..31.
- wxDateTime_t wxDateTime::Tm::min
- Minutos en el rango 0..59.
- Month wxDateTime::Tm::mon
- Mes, como constante enumerada.
- wxDateTime_t wxDateTime::Tm::msec
- Número de milisegundos.
- wxDateTime_t wxDateTime::Tm::sec
- Segundos en el rango 0..59. (60 con segundos bisiestos)
- wxDateTime_t wxDateTime::Tm::yday
- Día del año en el rango 0..365.
- int wxDateTime::Tm::year
- Año.
Funciones miembro
GetWeekDay()
WeekDay wxDateTime::Tm::GetWeekDay()
Devuelve el día de la semana correspondiente a esta fecha.
A diferencia de los demás campos, el día de la semana no siempre está disponible, por lo que debe accederse a él mediante este método, ya que se calcula bajo demanda cuando se llama.
IsValid()
bool wxDateTime::Tm::IsValid() const
Comprueba si la fecha/hora dada es válida (en calendario gregoriano).
Devuelve false si los componentes no corresponden a una fecha correcta.