#endif // broken strptime()
#ifndef WX_TIMEZONE
- #if defined(__MINGW32__) || defined(__VISAGECPP__)
+ #if defined(__BORLANDC__) || defined(__MINGW32__) || defined(__VISAGECPP__)
#define WX_TIMEZONE _timezone
#else // unknown platform - try timezone
#define WX_TIMEZONE timezone
wxDateTime::Tm wxDateTime::GetTm(const TimeZone& tz) const
{
+#ifdef __VMS__
+ int time2;
+#endif
wxASSERT_MSG( IsValid(), _T("invalid wxDateTime") );
time_t time = GetTicks();
else
{
time += tz.GetOffset();
- if ( time >= 0 )
+#ifdef __VMS__ /* time is unsigned so VMS gives a warning on the original */
+ time2 = (int) time;
+ if ( time2 >= 0 )
+#else
+ if ( time >= 0 )
+#endif
{
tm = gmtime(&time);
wxDateTime& wxDateTime::SetToYearDay(wxDateTime::wxDateTime_t yday)
{
int year = GetYear();
- wxCHECK_MSG( (0 < yday) && (yday < GetNumberOfDays(year)),
+ wxCHECK_MSG( (0 < yday) && (yday <= GetNumberOfDays(year)),
ms_InvDateTime, _T("invalid year day") );
bool isLeap = IsLeapYear(year);
wxString wxDateTime::Format(const wxChar *format, const TimeZone& tz) const
{
+#ifdef __VMS__
+ int time2;
+#endif
wxCHECK_MSG( format, _T(""), _T("NULL format in wxDateTime::Format") );
time_t time = GetTicks();
{
time += tz.GetOffset();
- if ( time >= 0 )
+#ifdef __VMS__ /* time is unsigned so VMS gives a warning on the original */
+ time2 = (int) time;
+ if ( time2 >= 0 )
+#else
+ if ( time >= 0 )
+#endif
{
tm = gmtime(&time);
// the spec was correct
Set(day, mon, year, hour, min, sec);
- MakeTimezone(60*offset);
+ MakeTimezone(60*(wxDateTime_t)offset);
return p;
}
return (wxChar *)NULL;
}
+ Tm tm = dt.GetTm();
+
+ haveDay = haveMon = haveYear =
+ haveHour = haveMin = haveSec = TRUE;
+
+ hour = tm.hour;
+ min = tm.min;
+ sec = tm.sec;
+
+ year = tm.year;
+ mon = tm.mon;
+ mday = tm.mday;
+
input = result;
}
break;
}
haveMon = TRUE;
- mon = (Month)num;
+ mon = (Month)(num - 1);
break;
case _T('M'): // minute as a decimal number (00-59)
min = tm.min;
sec = tm.sec;
}
+ break;
case _T('w'): // weekday as a number (0-6), Sunday = 0
if ( !GetNumericToken(input, &num) || (wday > 6) )
break;
case _T('Y'): // year with century
- if ( !GetNumericToken(input, &num) || !num || (num > 366) )
+ if ( !GetNumericToken(input, &num) )
{
// no match
return (wxChar *)NULL;
}
- haveYDay = TRUE;
- yday = (wxDateTime_t)num;
+ haveYear = TRUE;
+ year = (wxDateTime_t)num;
break;
case _T('Z'): // timezone name
// take this date as default
tmDef = dateDef.GetTm();
}
- else if ( IsValid() )
+ else if ( m_time != 0 )
{
// if this date is valid, don't change it
tmDef = GetTm();
// also always ignore the week day
if ( haveMon && haveDay )
{
+ if ( mday > GetNumOfDaysInMonth(tm.year, mon) )
+ {
+ wxLogDebug(_T("bad month day in wxDateTime::ParseFormat"));
+
+ return (wxChar *)NULL;
+ }
+
tm.mon = mon;
tm.mday = mday;
}
else if ( haveYDay )
{
+ if ( yday > GetNumberOfDays(tm.year) )
+ {
+ wxLogDebug(_T("bad year day in wxDateTime::ParseFormat"));
+
+ return (wxChar *)NULL;
+ }
+
Tm tm2 = wxDateTime(1, Jan, tm.year).SetToYearDay(yday).GetTm();
tm.mon = tm2.mon;