Add wxDateTime::GetWeekBasedYear().

It was just added as a private function to implement %V format specifier
support, just extract and document it as it could possibly be useful in its
own right.

See #11857.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76989 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2014-08-03 12:47:41 +00:00
parent 29b68052bb
commit 1b90acc357
5 changed files with 49 additions and 26 deletions

View File

@@ -1946,6 +1946,28 @@ wxDateTime::GetWeekOfYear(wxDateTime::WeekFlags flags, const TimeZone& tz) const
return (wxDateTime::wxDateTime_t)week;
}
int wxDateTime::GetWeekBasedYear(const TimeZone& tz) const
{
const wxDateTime::Tm tm = GetTm(tz);
int year = tm.year;
// The week-based year can only be different from the normal year for few
// days in the beginning and the end of the year.
if ( tm.yday > 361 )
{
if ( GetWeekOfYear(Monday_First, tz) == 1 )
year++;
}
else if ( tm.yday < 5 )
{
if ( GetWeekOfYear(Monday_First, tz) == 53 )
year--;
}
return year;
}
wxDateTime::wxDateTime_t wxDateTime::GetWeekOfMonth(wxDateTime::WeekFlags flags,
const TimeZone& tz) const
{