projects
/
wxWidgets.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Correct the direction passed to wxDataObject in wxGTK clipboard code.
[wxWidgets.git]
/
src
/
common
/
datetimefmt.cpp
diff --git
a/src/common/datetimefmt.cpp
b/src/common/datetimefmt.cpp
index e6544edd235e16bb769adb1c5ce5d3ba38bdacd3..254c7034369f516ddc61a8fb9e6e35960acd9293 100644
(file)
--- a/
src/common/datetimefmt.cpp
+++ b/
src/common/datetimefmt.cpp
@@
-311,7
+311,7
@@
ParseFormatAt(wxString::const_iterator& p,
wxString wxDateTime::Format(const wxString& formatp, const TimeZone& tz) const
{
wxCHECK_MSG( !formatp.empty(), wxEmptyString,
wxString wxDateTime::Format(const wxString& formatp, const TimeZone& tz) const
{
wxCHECK_MSG( !formatp.empty(), wxEmptyString,
-
_
T("NULL format in wxDateTime::Format") );
+
wx
T("NULL format in wxDateTime::Format") );
wxString format = formatp;
#ifdef __WXOSX__
wxString format = formatp;
#ifdef __WXOSX__
@@
-320,11
+320,11
@@
wxString wxDateTime::Format(const wxString& formatp, const TimeZone& tz) const
format.Replace("%X",wxLocale::GetInfo(wxLOCALE_TIME_FMT));
#endif
// we have to use our own implementation if the date is out of range of
format.Replace("%X",wxLocale::GetInfo(wxLOCALE_TIME_FMT));
#endif
// we have to use our own implementation if the date is out of range of
- // strftime() or if we use non standard specifi
cato
rs
+ // strftime() or if we use non standard specifi
e
rs
#ifdef wxHAS_STRFTIME
time_t time = GetTicks();
#ifdef wxHAS_STRFTIME
time_t time = GetTicks();
- if ( (time != (time_t)-1) && !wxStrstr(format,
_
T("%l")) )
+ if ( (time != (time_t)-1) && !wxStrstr(format,
wx
T("%l")) )
{
// use strftime()
struct tm tmstruct;
{
// use strftime()
struct tm tmstruct;
@@
-335,7
+335,7
@@
wxString wxDateTime::Format(const wxString& formatp, const TimeZone& tz) const
tm = wxLocaltime_r(&time, &tmstruct);
// should never happen
tm = wxLocaltime_r(&time, &tmstruct);
// should never happen
- wxCHECK_MSG( tm, wxEmptyString,
_
T("wxLocaltime_r() failed") );
+ wxCHECK_MSG( tm, wxEmptyString,
wx
T("wxLocaltime_r() failed") );
}
else
{
}
else
{
@@
-351,7
+351,7
@@
wxString wxDateTime::Format(const wxString& formatp, const TimeZone& tz) const
tm = wxGmtime_r(&time, &tmstruct);
// should never happen
tm = wxGmtime_r(&time, &tmstruct);
// should never happen
- wxCHECK_MSG( tm, wxEmptyString,
_
T("wxGmtime_r() failed") );
+ wxCHECK_MSG( tm, wxEmptyString,
wx
T("wxGmtime_r() failed") );
}
else
{
}
else
{
@@
-374,12
+374,11
@@
wxString wxDateTime::Format(const wxString& formatp, const TimeZone& tz) const
// used for calls to strftime() when we only deal with time
struct tm tmTimeOnly;
// used for calls to strftime() when we only deal with time
struct tm tmTimeOnly;
+ memset(&tmTimeOnly, 0, sizeof(tmTimeOnly));
tmTimeOnly.tm_hour = tm.hour;
tmTimeOnly.tm_min = tm.min;
tmTimeOnly.tm_sec = tm.sec;
tmTimeOnly.tm_hour = tm.hour;
tmTimeOnly.tm_min = tm.min;
tmTimeOnly.tm_sec = tm.sec;
- tmTimeOnly.tm_wday = 0;
- tmTimeOnly.tm_yday = 0;
- tmTimeOnly.tm_mday = 1; // any date will do
+ tmTimeOnly.tm_mday = 1; // any date will do, use 1976-01-01
tmTimeOnly.tm_mon = 0;
tmTimeOnly.tm_year = 76;
tmTimeOnly.tm_isdst = 0; // no DST, we adjust for tz ourselves
tmTimeOnly.tm_mon = 0;
tmTimeOnly.tm_year = 76;
tmTimeOnly.tm_isdst = 0; // no DST, we adjust for tz ourselves
@@
-387,7
+386,7
@@
wxString wxDateTime::Format(const wxString& formatp, const TimeZone& tz) const
wxString tmp, res, fmt;
for ( wxString::const_iterator p = format.begin(); p != format.end(); ++p )
{
wxString tmp, res, fmt;
for ( wxString::const_iterator p = format.begin(); p != format.end(); ++p )
{
- if ( *p !=
_
T('%') )
+ if ( *p !=
wx
T('%') )
{
// copy as is
res += *p;
{
// copy as is
res += *p;
@@
-398,17
+397,17
@@
wxString wxDateTime::Format(const wxString& formatp, const TimeZone& tz) const
// set the default format
switch ( (*++p).GetValue() )
{
// set the default format
switch ( (*++p).GetValue() )
{
- case
_
T('Y'): // year has 4 digits
- fmt =
_
T("%04d");
+ case
wx
T('Y'): // year has 4 digits
+ fmt =
wx
T("%04d");
break;
break;
- case
_
T('j'): // day of year has 3 digits
- case
_
T('l'): // milliseconds have 3 digits
- fmt =
_
T("%03d");
+ case
wx
T('j'): // day of year has 3 digits
+ case
wx
T('l'): // milliseconds have 3 digits
+ fmt =
wx
T("%03d");
break;
break;
- case
_
T('w'): // week day as number has only one
- fmt =
_
T("%d");
+ case
wx
T('w'): // week day as number has only one
+ fmt =
wx
T("%d");
break;
default:
break;
default:
@@
-416,7
+415,7
@@
wxString wxDateTime::Format(const wxString& formatp, const TimeZone& tz) const
// the format is "%02d" (for all the rest) or we have the
// field width preceding the format in which case it will
// override the default format anyhow
// the format is "%02d" (for all the rest) or we have the
// field width preceding the format in which case it will
// override the default format anyhow
- fmt =
_
T("%02d");
+ fmt =
wx
T("%02d");
}
bool restart = true;
}
bool restart = true;
@@
-427,21
+426,21
@@
wxString wxDateTime::Format(const wxString& formatp, const TimeZone& tz) const
// start of the format specification
switch ( (*p).GetValue() )
{
// start of the format specification
switch ( (*p).GetValue() )
{
- case
_
T('a'): // a weekday name
- case
_
T('A'):
+ case
wx
T('a'): // a weekday name
+ case
wx
T('A'):
// second parameter should be true for abbreviated names
res += GetWeekDayName(tm.GetWeekDay(),
// second parameter should be true for abbreviated names
res += GetWeekDayName(tm.GetWeekDay(),
- *p ==
_
T('a') ? Name_Abbr : Name_Full);
+ *p ==
wx
T('a') ? Name_Abbr : Name_Full);
break;
break;
- case
_
T('b'): // a month name
- case
_
T('B'):
+ case
wx
T('b'): // a month name
+ case
wx
T('B'):
res += GetMonthName(tm.mon,
res += GetMonthName(tm.mon,
- *p ==
_
T('b') ? Name_Abbr : Name_Full);
+ *p ==
wx
T('b') ? Name_Abbr : Name_Full);
break;
break;
- case
_
T('c'): // locale default date and time representation
- case
_
T('x'): // locale default date representation
+ case
wx
T('c'): // locale default date and time representation
+ case
wx
T('x'): // locale default date representation
#ifdef wxHAS_STRFTIME
//
// the problem: there is no way to know what do these format
#ifdef wxHAS_STRFTIME
//
// the problem: there is no way to know what do these format
@@
-513,7
+512,7
@@
wxString wxDateTime::Format(const wxString& formatp, const TimeZone& tz) const
year -= 28;
wxASSERT_MSG( year >= 1970 && year < 2000,
year -= 28;
wxASSERT_MSG( year >= 1970 && year < 2000,
-
_
T("logic error in wxDateTime::Format") );
+
wx
T("logic error in wxDateTime::Format") );
// use strftime() to format the same date but in supported
// use strftime() to format the same date but in supported
@@
-534,8
+533,8
@@
wxString wxDateTime::Format(const wxString& formatp, const TimeZone& tz) const
tmAdjusted.tm_mon = tm.mon;
tmAdjusted.tm_year = year - 1900;
tmAdjusted.tm_isdst = 0; // no DST, already adjusted
tmAdjusted.tm_mon = tm.mon;
tmAdjusted.tm_year = year - 1900;
tmAdjusted.tm_isdst = 0; // no DST, already adjusted
- wxString str = CallStrftime(*p ==
_T('c') ? _
T("%c")
- :
_
T("%x"),
+ wxString str = CallStrftime(*p ==
wxT('c') ? wx
T("%c")
+ :
wx
T("%x"),
&tmAdjusted);
// now replace the replacement year with the real year:
&tmAdjusted);
// now replace the replacement year with the real year:
@@
-565,15
+564,15
@@
wxString wxDateTime::Format(const wxString& formatp, const TimeZone& tz) const
#endif // wxHAS_STRFTIME/!wxHAS_STRFTIME
break;
#endif // wxHAS_STRFTIME/!wxHAS_STRFTIME
break;
- case
_
T('d'): // day of a month (01-31)
+ case
wx
T('d'): // day of a month (01-31)
res += wxString::Format(fmt, tm.mday);
break;
res += wxString::Format(fmt, tm.mday);
break;
- case
_
T('H'): // hour in 24h format (00-23)
+ case
wx
T('H'): // hour in 24h format (00-23)
res += wxString::Format(fmt, tm.hour);
break;
res += wxString::Format(fmt, tm.hour);
break;
- case
_
T('I'): // hour in 12h format (01-12)
+ case
wx
T('I'): // hour in 12h format (01-12)
{
// 24h -> 12h, 0h -> 12h too
int hour12 = tm.hour > 12 ? tm.hour - 12
{
// 24h -> 12h, 0h -> 12h too
int hour12 = tm.hour > 12 ? tm.hour - 12
@@
-582,76
+581,77
@@
wxString wxDateTime::Format(const wxString& formatp, const TimeZone& tz) const
}
break;
}
break;
- case
_
T('j'): // day of the year
+ case
wx
T('j'): // day of the year
res += wxString::Format(fmt, GetDayOfYear(tz));
break;
res += wxString::Format(fmt, GetDayOfYear(tz));
break;
- case
_
T('l'): // milliseconds (NOT STANDARD)
+ case
wx
T('l'): // milliseconds (NOT STANDARD)
res += wxString::Format(fmt, GetMillisecond(tz));
break;
res += wxString::Format(fmt, GetMillisecond(tz));
break;
- case
_
T('m'): // month as a number (01-12)
+ case
wx
T('m'): // month as a number (01-12)
res += wxString::Format(fmt, tm.mon + 1);
break;
res += wxString::Format(fmt, tm.mon + 1);
break;
- case
_
T('M'): // minute as a decimal number (00-59)
+ case
wx
T('M'): // minute as a decimal number (00-59)
res += wxString::Format(fmt, tm.min);
break;
res += wxString::Format(fmt, tm.min);
break;
- case
_
T('p'): // AM or PM string
+ case
wx
T('p'): // AM or PM string
#ifdef wxHAS_STRFTIME
#ifdef wxHAS_STRFTIME
- res += CallStrftime(
_
T("%p"), &tmTimeOnly);
+ res += CallStrftime(
wx
T("%p"), &tmTimeOnly);
#else // !wxHAS_STRFTIME
res += (tmTimeOnly.tm_hour > 12) ? wxT("pm") : wxT("am");
#endif // wxHAS_STRFTIME/!wxHAS_STRFTIME
break;
#else // !wxHAS_STRFTIME
res += (tmTimeOnly.tm_hour > 12) ? wxT("pm") : wxT("am");
#endif // wxHAS_STRFTIME/!wxHAS_STRFTIME
break;
- case
_
T('S'): // second as a decimal number (00-61)
+ case
wx
T('S'): // second as a decimal number (00-61)
res += wxString::Format(fmt, tm.sec);
break;
res += wxString::Format(fmt, tm.sec);
break;
- case
_
T('U'): // week number in the year (Sunday 1st week day)
+ case
wx
T('U'): // week number in the year (Sunday 1st week day)
res += wxString::Format(fmt, GetWeekOfYear(Sunday_First, tz));
break;
res += wxString::Format(fmt, GetWeekOfYear(Sunday_First, tz));
break;
- case
_
T('W'): // week number in the year (Monday 1st week day)
+ case
wx
T('W'): // week number in the year (Monday 1st week day)
res += wxString::Format(fmt, GetWeekOfYear(Monday_First, tz));
break;
res += wxString::Format(fmt, GetWeekOfYear(Monday_First, tz));
break;
- case
_
T('w'): // weekday as a number (0-6), Sunday = 0
+ case
wx
T('w'): // weekday as a number (0-6), Sunday = 0
res += wxString::Format(fmt, tm.GetWeekDay());
break;
res += wxString::Format(fmt, tm.GetWeekDay());
break;
- // case
_
T('x'): -- handled with "%c"
+ // case
wx
T('x'): -- handled with "%c"
- case
_
T('X'): // locale default time representation
+ case
wx
T('X'): // locale default time representation
// just use strftime() to format the time for us
#ifdef wxHAS_STRFTIME
// just use strftime() to format the time for us
#ifdef wxHAS_STRFTIME
- res += CallStrftime(
_
T("%X"), &tmTimeOnly);
+ res += CallStrftime(
wx
T("%X"), &tmTimeOnly);
#else // !wxHAS_STRFTIME
res += wxString::Format(wxT("%02d:%02d:%02d"),tm.hour, tm.min, tm.sec);
#endif // wxHAS_STRFTIME/!wxHAS_STRFTIME
break;
#else // !wxHAS_STRFTIME
res += wxString::Format(wxT("%02d:%02d:%02d"),tm.hour, tm.min, tm.sec);
#endif // wxHAS_STRFTIME/!wxHAS_STRFTIME
break;
- case
_
T('y'): // year without century (00-99)
+ case
wx
T('y'): // year without century (00-99)
res += wxString::Format(fmt, tm.year % 100);
break;
res += wxString::Format(fmt, tm.year % 100);
break;
- case
_
T('Y'): // year with century
+ case
wx
T('Y'): // year with century
res += wxString::Format(fmt, tm.year);
break;
res += wxString::Format(fmt, tm.year);
break;
- case
_
T('Z'): // timezone name
+ case
wx
T('Z'): // timezone name
#ifdef wxHAS_STRFTIME
#ifdef wxHAS_STRFTIME
- res += CallStrftime(
_
T("%Z"), &tmTimeOnly);
+ res += CallStrftime(
wx
T("%Z"), &tmTimeOnly);
#endif
break;
default:
// is it the format width?
#endif
break;
default:
// is it the format width?
- fmt.Empty();
- while ( *p == _T('-') || *p == _T('+') ||
- *p == _T(' ') || wxIsdigit(*p) )
+ for ( fmt.clear();
+ *p == wxT('-') || *p == wxT('+') ||
+ *p == wxT(' ') || wxIsdigit(*p);
+ ++p )
{
fmt += *p;
}
{
fmt += *p;
}
@@
-659,8
+659,8
@@
wxString wxDateTime::Format(const wxString& formatp, const TimeZone& tz) const
if ( !fmt.empty() )
{
// we've only got the flags and width so far in fmt
if ( !fmt.empty() )
{
// we've only got the flags and width so far in fmt
- fmt.Prepend(
_
T('%'));
- fmt.Append(
_
T('d'));
+ fmt.Prepend(
wx
T('%'));
+ fmt.Append(
wx
T('d'));
restart = true;
restart = true;
@@
-668,19
+668,19
@@
wxString wxDateTime::Format(const wxString& formatp, const TimeZone& tz) const
}
// no, it wasn't the width
}
// no, it wasn't the width
- wxFAIL_MSG(
_T("unknown format specificato
r"));
+ wxFAIL_MSG(
wxT("unknown format specifie
r"));
// fall through and just copy it nevertheless
// fall through and just copy it nevertheless
- case
_
T('%'): // a percent sign
+ case
wx
T('%'): // a percent sign
res += *p;
break;
case 0: // the end of string
res += *p;
break;
case 0: // the end of string
- wxFAIL_MSG(
_
T("missing format at the end of string"));
+ wxFAIL_MSG(
wx
T("missing format at the end of string"));
// just put the '%' which was the last char in format
// just put the '%' which was the last char in format
- res +=
_
T('%');
+ res +=
wx
T('%');
break;
}
}
break;
}
}
@@
-852,7
+852,7
@@
wxDateTime::ParseRfc822Date(const wxString& date, wxString::const_iterator *end)
+1, +2, +3, +4, +5, +6, +7, +8, +9, +10, +11, +12, 0
};
+1, +2, +3, +4, +5, +6, +7, +8, +9, +10, +11, +12, 0
};
- if ( *p <
_T('A') || *p > _T('Z') || *p == _
T('J') )
+ if ( *p <
wxT('A') || *p > wxT('Z') || *p == wx
T('J') )
return false;
offset = offsets[*p++ - 'A'];
return false;
offset = offsets[*p++ - 'A'];
@@
-861,27
+861,27
@@
wxDateTime::ParseRfc822Date(const wxString& date, wxString::const_iterator *end)
{
// abbreviation
const wxString tz(p, date.end());
{
// abbreviation
const wxString tz(p, date.end());
- if ( tz ==
_T("UT") || tz == _T("UTC") || tz == _
T("GMT") )
+ if ( tz ==
wxT("UT") || tz == wxT("UTC") || tz == wx
T("GMT") )
offset = 0;
offset = 0;
- else if ( tz ==
_
T("AST") )
+ else if ( tz ==
wx
T("AST") )
offset = AST - GMT0;
offset = AST - GMT0;
- else if ( tz ==
_
T("ADT") )
+ else if ( tz ==
wx
T("ADT") )
offset = ADT - GMT0;
offset = ADT - GMT0;
- else if ( tz ==
_
T("EST") )
+ else if ( tz ==
wx
T("EST") )
offset = EST - GMT0;
offset = EST - GMT0;
- else if ( tz ==
_
T("EDT") )
+ else if ( tz ==
wx
T("EDT") )
offset = EDT - GMT0;
offset = EDT - GMT0;
- else if ( tz ==
_
T("CST") )
+ else if ( tz ==
wx
T("CST") )
offset = CST - GMT0;
offset = CST - GMT0;
- else if ( tz ==
_
T("CDT") )
+ else if ( tz ==
wx
T("CDT") )
offset = CDT - GMT0;
offset = CDT - GMT0;
- else if ( tz ==
_
T("MST") )
+ else if ( tz ==
wx
T("MST") )
offset = MST - GMT0;
offset = MST - GMT0;
- else if ( tz ==
_
T("MDT") )
+ else if ( tz ==
wx
T("MDT") )
offset = MDT - GMT0;
offset = MDT - GMT0;
- else if ( tz ==
_
T("PST") )
+ else if ( tz ==
wx
T("PST") )
offset = PST - GMT0;
offset = PST - GMT0;
- else if ( tz ==
_
T("PDT") )
+ else if ( tz ==
wx
T("PDT") )
offset = PDT - GMT0;
else
return false;
offset = PDT - GMT0;
else
return false;
@@
-945,7
+945,7
@@
wxDateTime::ParseFormat(const wxString& date,
const wxString::const_iterator end = date.end();
for ( wxString::const_iterator fmt = format.begin(); fmt != format.end(); ++fmt )
{
const wxString::const_iterator end = date.end();
for ( wxString::const_iterator fmt = format.begin(); fmt != format.end(); ++fmt )
{
- if ( *fmt !=
_
T('%') )
+ if ( *fmt !=
wx
T('%') )
{
if ( wxIsspace(*fmt) )
{
{
if ( wxIsspace(*fmt) )
{
@@
-986,16
+986,16
@@
wxDateTime::ParseFormat(const wxString& date,
{
switch ( (*fmt).GetValue() )
{
{
switch ( (*fmt).GetValue() )
{
- case
_
T('Y'): // year has 4 digits
+ case
wx
T('Y'): // year has 4 digits
width = 4;
break;
width = 4;
break;
- case
_
T('j'): // day of year has 3 digits
- case
_
T('l'): // milliseconds have 3 digits
+ case
wx
T('j'): // day of year has 3 digits
+ case
wx
T('l'): // milliseconds have 3 digits
width = 3;
break;
width = 3;
break;
- case
_
T('w'): // week day as number has only one
+ case
wx
T('w'): // week day as number has only one
width = 1;
break;
width = 1;
break;
@@
-1008,8
+1008,8
@@
wxDateTime::ParseFormat(const wxString& date,
// then the format itself
switch ( (*fmt).GetValue() )
{
// then the format itself
switch ( (*fmt).GetValue() )
{
- case
_
T('a'): // a weekday name
- case
_
T('A'):
+ case
wx
T('a'): // a weekday name
+ case
wx
T('A'):
{
wday = GetWeekDayFromName
(
{
wday = GetWeekDayFromName
(
@@
-1026,8
+1026,8
@@
wxDateTime::ParseFormat(const wxString& date,
haveWDay = true;
break;
haveWDay = true;
break;
- case
_
T('b'): // a month name
- case
_
T('B'):
+ case
wx
T('b'): // a month name
+ case
wx
T('B'):
{
mon = GetMonthFromName
(
{
mon = GetMonthFromName
(
@@
-1044,15
+1044,16
@@
wxDateTime::ParseFormat(const wxString& date,
haveMon = true;
break;
haveMon = true;
break;
- case
_
T('c'): // locale default date and time representation
+ case
wx
T('c'): // locale default date and time representation
{
wxDateTime dt;
{
wxDateTime dt;
+#if wxUSE_INTL
const wxString
fmtDateTime = wxLocale::GetInfo(wxLOCALE_DATE_TIME_FMT);
if ( !fmtDateTime.empty() )
dt = ParseFormatAt(input, end, fmtDateTime);
const wxString
fmtDateTime = wxLocale::GetInfo(wxLOCALE_DATE_TIME_FMT);
if ( !fmtDateTime.empty() )
dt = ParseFormatAt(input, end, fmtDateTime);
-
+#endif // wxUSE_INTL
if ( !dt.IsValid() )
{
// also try the format which corresponds to ctime()
if ( !dt.IsValid() )
{
// also try the format which corresponds to ctime()
@@
-1084,7
+1085,8
@@
wxDateTime::ParseFormat(const wxString& date,
}
break;
}
break;
- case _T('d'): // day of a month (01-31)
+ case wxT('d'): // day of a month (01-31)
+ case 'e': // day of a month (1-31) (GNU extension)
if ( !GetNumericToken(width, input, end, &num) ||
(num > 31) || (num < 1) )
{
if ( !GetNumericToken(width, input, end, &num) ||
(num > 31) || (num < 1) )
{
@@
-1098,7
+1100,7
@@
wxDateTime::ParseFormat(const wxString& date,
mday = (wxDateTime_t)num;
break;
mday = (wxDateTime_t)num;
break;
- case
_
T('H'): // hour in 24h format (00-23)
+ case
wx
T('H'): // hour in 24h format (00-23)
if ( !GetNumericToken(width, input, end, &num) || (num > 23) )
{
// no match
if ( !GetNumericToken(width, input, end, &num) || (num > 23) )
{
// no match
@@
-1109,7
+1111,7
@@
wxDateTime::ParseFormat(const wxString& date,
hour = (wxDateTime_t)num;
break;
hour = (wxDateTime_t)num;
break;
- case
_
T('I'): // hour in 12h format (01-12)
+ case
wx
T('I'): // hour in 12h format (01-12)
if ( !GetNumericToken(width, input, end, &num) ||
!num || (num > 12) )
{
if ( !GetNumericToken(width, input, end, &num) ||
!num || (num > 12) )
{
@@
-1122,7
+1124,7
@@
wxDateTime::ParseFormat(const wxString& date,
hour = (wxDateTime_t)(num % 12); // 12 should be 0
break;
hour = (wxDateTime_t)(num % 12); // 12 should be 0
break;
- case
_
T('j'): // day of the year
+ case
wx
T('j'): // day of the year
if ( !GetNumericToken(width, input, end, &num) ||
!num || (num > 366) )
{
if ( !GetNumericToken(width, input, end, &num) ||
!num || (num > 366) )
{
@@
-1134,7
+1136,7
@@
wxDateTime::ParseFormat(const wxString& date,
yday = (wxDateTime_t)num;
break;
yday = (wxDateTime_t)num;
break;
- case
_
T('l'): // milliseconds (0-999)
+ case
wx
T('l'): // milliseconds (0-999)
if ( !GetNumericToken(width, input, end, &num) )
return false;
if ( !GetNumericToken(width, input, end, &num) )
return false;
@@
-1142,7
+1144,7
@@
wxDateTime::ParseFormat(const wxString& date,
msec = (wxDateTime_t)num;
break;
msec = (wxDateTime_t)num;
break;
- case
_
T('m'): // month as a number (01-12)
+ case
wx
T('m'): // month as a number (01-12)
if ( !GetNumericToken(width, input, end, &num) ||
!num || (num > 12) )
{
if ( !GetNumericToken(width, input, end, &num) ||
!num || (num > 12) )
{
@@
-1154,7
+1156,7
@@
wxDateTime::ParseFormat(const wxString& date,
mon = (Month)(num - 1);
break;
mon = (Month)(num - 1);
break;
- case
_
T('M'): // minute as a decimal number (00-59)
+ case
wx
T('M'): // minute as a decimal number (00-59)
if ( !GetNumericToken(width, input, end, &num) ||
(num > 59) )
{
if ( !GetNumericToken(width, input, end, &num) ||
(num > 59) )
{
@@
-1166,7
+1168,7
@@
wxDateTime::ParseFormat(const wxString& date,
min = (wxDateTime_t)num;
break;
min = (wxDateTime_t)num;
break;
- case
_
T('p'): // AM or PM string
+ case
wx
T('p'): // AM or PM string
{
wxString am, pm;
GetAmPmStrings(&am, &pm);
{
wxString am, pm;
GetAmPmStrings(&am, &pm);
@@
-1192,7
+1194,7
@@
wxDateTime::ParseFormat(const wxString& date,
}
break;
}
break;
- case
_
T('r'): // time as %I:%M:%S %p
+ case
wx
T('r'): // time as %I:%M:%S %p
{
wxDateTime dt;
if ( !dt.ParseFormat(wxString(input, end),
{
wxDateTime dt;
if ( !dt.ParseFormat(wxString(input, end),
@@
-1208,7
+1210,7
@@
wxDateTime::ParseFormat(const wxString& date,
}
break;
}
break;
- case
_
T('R'): // time as %H:%M
+ case
wx
T('R'): // time as %H:%M
{
const wxDateTime
dt = ParseFormatAt(input, end, wxS("%H:%M"));
{
const wxDateTime
dt = ParseFormatAt(input, end, wxS("%H:%M"));
@@
-1224,7
+1226,7
@@
wxDateTime::ParseFormat(const wxString& date,
}
break;
}
break;
- case
_
T('S'): // second as a decimal number (00-61)
+ case
wx
T('S'): // second as a decimal number (00-61)
if ( !GetNumericToken(width, input, end, &num) ||
(num > 61) )
{
if ( !GetNumericToken(width, input, end, &num) ||
(num > 61) )
{
@@
-1236,7
+1238,7
@@
wxDateTime::ParseFormat(const wxString& date,
sec = (wxDateTime_t)num;
break;
sec = (wxDateTime_t)num;
break;
- case
_
T('T'): // time as %H:%M:%S
+ case
wx
T('T'): // time as %H:%M:%S
{
const wxDateTime
dt = ParseFormatAt(input, end, wxS("%H:%M:%S"));
{
const wxDateTime
dt = ParseFormatAt(input, end, wxS("%H:%M:%S"));
@@
-1254,7
+1256,7
@@
wxDateTime::ParseFormat(const wxString& date,
}
break;
}
break;
- case
_
T('w'): // weekday as a number (0-6), Sunday = 0
+ case
wx
T('w'): // weekday as a number (0-6), Sunday = 0
if ( !GetNumericToken(width, input, end, &num) ||
(wday > 6) )
{
if ( !GetNumericToken(width, input, end, &num) ||
(wday > 6) )
{
@@
-1266,12
+1268,15
@@
wxDateTime::ParseFormat(const wxString& date,
wday = (WeekDay)num;
break;
wday = (WeekDay)num;
break;
- case
_
T('x'): // locale default date representation
+ case
wx
T('x'): // locale default date representation
{
{
+#if wxUSE_INTL
wxString
fmtDate = wxLocale::GetInfo(wxLOCALE_SHORT_DATE_FMT),
fmtDateAlt = wxLocale::GetInfo(wxLOCALE_LONG_DATE_FMT);
wxString
fmtDate = wxLocale::GetInfo(wxLOCALE_SHORT_DATE_FMT),
fmtDateAlt = wxLocale::GetInfo(wxLOCALE_LONG_DATE_FMT);
-
+#else // !wxUSE_INTL
+ wxString fmtDate, fmtDateAlt;
+#endif // wxUSE_INTL/!wxUSE_INTL
if ( fmtDate.empty() )
{
if ( IsWestEuropeanCountry(GetCountry()) ||
if ( fmtDate.empty() )
{
if ( IsWestEuropeanCountry(GetCountry()) ||
@@
-1314,11
+1319,14
@@
wxDateTime::ParseFormat(const wxString& date,
break;
break;
- case
_
T('X'): // locale default time representation
+ case
wx
T('X'): // locale default time representation
{
{
+#if wxUSE_INTL
wxString fmtTime = wxLocale::GetInfo(wxLOCALE_TIME_FMT),
fmtTimeAlt;
wxString fmtTime = wxLocale::GetInfo(wxLOCALE_TIME_FMT),
fmtTimeAlt;
-
+#else // !wxUSE_INTL
+ wxString fmtTime, fmtTimeAlt;
+#endif // wxUSE_INTL/!wxUSE_INTL
if ( fmtTime.empty() )
{
// try to parse what follows as "%H:%M:%S" and, if this
if ( fmtTime.empty() )
{
// try to parse what follows as "%H:%M:%S" and, if this
@@
-1344,7
+1352,7
@@
wxDateTime::ParseFormat(const wxString& date,
}
break;
}
break;
- case
_
T('y'): // year without century (00-99)
+ case
wx
T('y'): // year without century (00-99)
if ( !GetNumericToken(width, input, end, &num) ||
(num > 99) )
{
if ( !GetNumericToken(width, input, end, &num) ||
(num > 99) )
{
@@
-1359,7
+1367,7
@@
wxDateTime::ParseFormat(const wxString& date,
year = (num > 30 ? 1900 : 2000) + (wxDateTime_t)num;
break;
year = (num > 30 ? 1900 : 2000) + (wxDateTime_t)num;
break;
- case
_
T('Y'): // year with century
+ case
wx
T('Y'): // year with century
if ( !GetNumericToken(width, input, end, &num) )
{
// no match
if ( !GetNumericToken(width, input, end, &num) )
{
// no match
@@
-1370,14
+1378,14
@@
wxDateTime::ParseFormat(const wxString& date,
year = (wxDateTime_t)num;
break;
year = (wxDateTime_t)num;
break;
- case
_
T('Z'): // timezone name
+ case
wx
T('Z'): // timezone name
// FIXME: currently we just ignore everything that looks like a
// time zone here
GetAlphaToken(input, end);
break;
// FIXME: currently we just ignore everything that looks like a
// time zone here
GetAlphaToken(input, end);
break;
- case
_
T('%'): // a percent sign
- if ( *input++ !=
_
T('%') )
+ case
wx
T('%'): // a percent sign
+ if ( *input++ !=
wx
T('%') )
{
// no match
return false;
{
// no match
return false;
@@
-1385,7
+1393,7
@@
wxDateTime::ParseFormat(const wxString& date,
break;
case 0: // the end of string
break;
case 0: // the end of string
- wxFAIL_MSG(
_
T("unexpected format end"));
+ wxFAIL_MSG(
wx
T("unexpected format end"));
// fall through
// fall through
@@
-1489,10
+1497,9
@@
wxDateTime::ParseDateTime(const wxString& date, wxString::const_iterator *end)
{
wxCHECK_MSG( end, false, "end iterator pointer must be specified" );
{
wxCHECK_MSG( end, false, "end iterator pointer must be specified" );
- // Set to current day and hour, so strings like '14:00' becomes today at
- // 14, not some other random date
- wxDateTime dtDate = wxDateTime::Today();
- wxDateTime dtTime = wxDateTime::Today();
+ wxDateTime
+ dtDate,
+ dtTime;
wxString::const_iterator
endTime,
wxString::const_iterator
endTime,
@@
-1551,7
+1558,7
@@
wxDateTime::ParseDate(const wxString& date, wxString::const_iterator *end)
const wxString::const_iterator pEnd = date.end();
wxString::const_iterator p = pBegin;
const wxString::const_iterator pEnd = date.end();
wxString::const_iterator p = pBegin;
- while ( wxIsspace(*p) )
+ while (
p != pEnd &&
wxIsspace(*p) )
p++;
// some special cases
p++;
// some special cases
@@
-1618,9
+1625,10
@@
wxDateTime::ParseDate(const wxString& date, wxString::const_iterator *end)
while ( p != pEnd )
{
// skip white space and date delimiters
while ( p != pEnd )
{
// skip white space and date delimiters
-
while
( wxStrchr(".,/-\t\r\n ", *p) )
+
if
( wxStrchr(".,/-\t\r\n ", *p) )
{
++p;
{
++p;
+ continue;
}
// modify copy of the iterator as we're not sure if the next token is
}
// modify copy of the iterator as we're not sure if the next token is
@@
-1752,7
+1760,7
@@
wxDateTime::ParseDate(const wxString& date, wxString::const_iterator *end)
else // not a valid weekday name
{
// try the ordinals
else // not a valid weekday name
{
// try the ordinals
- static const char *ordinals[] =
+ static const char *
const
ordinals[] =
{
wxTRANSLATE("first"),
wxTRANSLATE("second"),
{
wxTRANSLATE("first"),
wxTRANSLATE("second"),
@@
-1914,14
+1922,13
@@
wxDateTime::ParseTime(const wxString& time, wxString::const_iterator *end)
for ( size_t n = 0; n < WXSIZEOF(stdTimes); n++ )
{
const wxString timeString = wxGetTranslation(stdTimes[n].name);
for ( size_t n = 0; n < WXSIZEOF(stdTimes); n++ )
{
const wxString timeString = wxGetTranslation(stdTimes[n].name);
- const wxString::const_iterator p = time.begin() + timeString.length();
- if ( timeString.CmpNoCase(wxString(time.begin(), p)) == 0 )
+ if ( timeString.CmpNoCase(wxString(time, timeString.length())) == 0 )
{
// casts required by DigitalMars
Set(stdTimes[n].hour, wxDateTime_t(0), wxDateTime_t(0));
if ( end )
{
// casts required by DigitalMars
Set(stdTimes[n].hour, wxDateTime_t(0), wxDateTime_t(0));
if ( end )
- *end =
p
;
+ *end =
time.begin() + timeString.length()
;
return true;
}
return true;
}
@@
-1929,12
+1936,12
@@
wxDateTime::ParseTime(const wxString& time, wxString::const_iterator *end)
// try all time formats we may think about in the order from longest to
// shortest
// try all time formats we may think about in the order from longest to
// shortest
- static const char *timeFormats[] =
+ static const char *
const
timeFormats[] =
{
"%I:%M:%S %p", // 12hour with AM/PM
"%H:%M:%S", // could be the same or 24 hour one so try it too
"%I:%M %p", // 12hour with AM/PM but without seconds
{
"%I:%M:%S %p", // 12hour with AM/PM
"%H:%M:%S", // could be the same or 24 hour one so try it too
"%I:%M %p", // 12hour with AM/PM but without seconds
- "%H:%M
:%S",
// and a possibly 24 hour version without seconds
+ "%H:%M
",
// and a possibly 24 hour version without seconds
"%X", // possibly something from above or maybe something
// completely different -- try it last
"%X", // possibly something from above or maybe something
// completely different -- try it last
@@
-2018,7
+2025,7
@@
wxString wxTimeSpan::Format(const wxString& format) const
}
wxCHECK_MSG( !format.empty(), wxEmptyString,
}
wxCHECK_MSG( !format.empty(), wxEmptyString,
-
_
T("NULL format in wxTimeSpan::Format") );
+
wx
T("NULL format in wxTimeSpan::Format") );
wxString str;
str.Alloc(format.length());
wxString str;
str.Alloc(format.length());
@@
-2043,10
+2050,10
@@
wxString wxTimeSpan::Format(const wxString& format) const
{
wxChar ch = *pch;
{
wxChar ch = *pch;
- if ( ch ==
_
T('%') )
+ if ( ch ==
wx
T('%') )
{
// the start of the format specification of the printf() below
{
// the start of the format specification of the printf() below
- wxString fmtPrefix(
_
T('%'));
+ wxString fmtPrefix(
wx
T('%'));
// the number
long n;
// the number
long n;
@@
-2058,16
+2065,16
@@
wxString wxTimeSpan::Format(const wxString& format) const
switch ( ch )
{
default:
switch ( ch )
{
default:
- wxFAIL_MSG(
_
T("invalid format character") );
+ wxFAIL_MSG(
wx
T("invalid format character") );
// fall through
// fall through
- case
_
T('%'):
+ case
wx
T('%'):
str += ch;
// skip the part below switch
continue;
str += ch;
// skip the part below switch
continue;
- case
_
T('D'):
+ case
wx
T('D'):
n = GetDays();
if ( partBiggest < Part_Day )
{
n = GetDays();
if ( partBiggest < Part_Day )
{
@@
-2079,12
+2086,12
@@
wxString wxTimeSpan::Format(const wxString& format) const
}
break;
}
break;
- case
_
T('E'):
+ case
wx
T('E'):
partBiggest = Part_Week;
n = GetWeeks();
break;
partBiggest = Part_Week;
n = GetWeeks();
break;
- case
_
T('H'):
+ case
wx
T('H'):
n = GetHours();
if ( partBiggest < Part_Hour )
{
n = GetHours();
if ( partBiggest < Part_Hour )
{
@@
-2098,7
+2105,7
@@
wxString wxTimeSpan::Format(const wxString& format) const
digits = 2;
break;
digits = 2;
break;
- case
_
T('l'):
+ case
wx
T('l'):
n = GetMilliseconds().ToLong();
if ( partBiggest < Part_MSec )
{
n = GetMilliseconds().ToLong();
if ( partBiggest < Part_MSec )
{
@@
-2110,7
+2117,7
@@
wxString wxTimeSpan::Format(const wxString& format) const
digits = 3;
break;
digits = 3;
break;
- case
_
T('M'):
+ case
wx
T('M'):
n = GetMinutes();
if ( partBiggest < Part_Min )
{
n = GetMinutes();
if ( partBiggest < Part_Min )
{
@@
-2124,7
+2131,7
@@
wxString wxTimeSpan::Format(const wxString& format) const
digits = 2;
break;
digits = 2;
break;
- case
_
T('S'):
+ case
wx
T('S'):
n = GetSeconds().ToLong();
if ( partBiggest < Part_Sec )
{
n = GetSeconds().ToLong();
if ( partBiggest < Part_Sec )
{
@@
-2141,10
+2148,10
@@
wxString wxTimeSpan::Format(const wxString& format) const
if ( digits )
{
if ( digits )
{
- fmtPrefix <<
_
T("0") << digits;
+ fmtPrefix <<
wx
T("0") << digits;
}
}
- str += wxString::Format(fmtPrefix +
_
T("ld"), n);
+ str += wxString::Format(fmtPrefix +
wx
T("ld"), n);
}
else
{
}
else
{