X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b5f85206a9b4b8771015022adfcc58cde08a0936..fcdd53359135f790b85728c4254b97095a56dad8:/src/common/datetime.cpp diff --git a/src/common/datetime.cpp b/src/common/datetime.cpp index 0a58ed3f86..16ccbc4094 100644 --- a/src/common/datetime.cpp +++ b/src/common/datetime.cpp @@ -381,7 +381,8 @@ extern const char *wxDumpDate(const wxDateTime* dt) static char buf[128]; wxString fmt(dt->Format("%Y-%m-%d (%a) %H:%M:%S")); - wxStrncpy(buf, fmt + " (" + dt->GetValue().ToString() + " ticks)", + wxStrlcpy(buf, + (fmt + " (" + dt->GetValue().ToString() + " ticks)").ToAscii(), WXSIZEOF(buf)); return buf; @@ -4273,6 +4274,14 @@ enum TimeSpanPart // %l milliseconds (000 - 999) wxString wxTimeSpan::Format(const wxString& format) const { + // we deal with only positive time spans here and just add the sign in + // front for the negative ones + if ( IsNegative() ) + { + wxString str(Negate().Format(format)); + return "-" + str; + } + wxCHECK_MSG( !format.empty(), wxEmptyString, _T("NULL format in wxTimeSpan::Format") ); @@ -4344,13 +4353,6 @@ wxString wxTimeSpan::Format(const wxString& format) const n = GetHours(); if ( partBiggest < Part_Hour ) { - if ( n < 0 ) - { - // the sign has already been taken into account - // when outputting the biggest part - n = -n; - } - n %= HOURS_PER_DAY; } else @@ -4365,9 +4367,6 @@ wxString wxTimeSpan::Format(const wxString& format) const n = GetMilliseconds().ToLong(); if ( partBiggest < Part_MSec ) { - if ( n < 0 ) - n = -n; - n %= 1000; } //else: no need to reset partBiggest to Part_MSec, it is @@ -4380,9 +4379,6 @@ wxString wxTimeSpan::Format(const wxString& format) const n = GetMinutes(); if ( partBiggest < Part_Min ) { - if ( n < 0 ) - n = -n; - n %= MIN_PER_HOUR; } else @@ -4397,9 +4393,6 @@ wxString wxTimeSpan::Format(const wxString& format) const n = GetSeconds().ToLong(); if ( partBiggest < Part_Sec ) { - if ( n < 0 ) - n = -n; - n %= SEC_PER_MIN; } else @@ -4413,10 +4406,6 @@ wxString wxTimeSpan::Format(const wxString& format) const if ( digits ) { - // negative numbers need one extra position for '-' display - if ( n < 0 ) - digits++; - fmtPrefix << _T("0") << digits; } @@ -4602,7 +4591,7 @@ WXDLLIMPEXP_BASE void wxPrevWDay(wxDateTime::WeekDay& wd) wxDateTime& wxDateTime::SetFromMSWSysTime(const SYSTEMTIME& st) { return Set(st.wDay, - wx_static_cast(wxDateTime::Month, wxDateTime::Jan + st.wMonth - 1), + static_cast(wxDateTime::Jan + st.wMonth - 1), st.wYear, 0, 0, 0); }