Merge branch 'firstweekday' of https://github.com/lanurmi/wxWidgets
Add API for determining the first day of the week and use it in wxCalendarCtrl. Closes https://github.com/wxWidgets/wxWidgets/pull/522
This commit is contained in:
@@ -27,7 +27,7 @@
|
||||
enum
|
||||
{
|
||||
// show Sunday as the first day of the week (default)
|
||||
wxCAL_SUNDAY_FIRST = 0x0000,
|
||||
wxCAL_SUNDAY_FIRST = 0x0080,
|
||||
|
||||
// show Monday as the first day of the week
|
||||
wxCAL_MONDAY_FIRST = 0x0001,
|
||||
@@ -332,6 +332,9 @@ protected:
|
||||
|
||||
// called by EnableHolidayDisplay()
|
||||
virtual void RefreshHolidays() { }
|
||||
|
||||
// does the week start on monday based on flags and OS settings?
|
||||
bool WeekStartsOnMonday() const;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@@ -392,6 +392,9 @@ public:
|
||||
// returns true if the given year is a leap year in the given calendar
|
||||
static bool IsLeapYear(int year = Inv_Year, Calendar cal = Gregorian);
|
||||
|
||||
// acquires the first day of week based on locale and/or OS settings
|
||||
static bool GetFirstWeekDay(WeekDay *firstDay);
|
||||
|
||||
// get the century (19 for 1999, 20 for 2000 and -5 for 492 BC)
|
||||
static int GetCentury(int year);
|
||||
|
||||
@@ -1142,6 +1145,9 @@ private:
|
||||
// functions
|
||||
inline bool IsInStdRange() const;
|
||||
|
||||
// assign the preferred first day of a week to flags, if necessary
|
||||
void UseEffectiveWeekDayFlags(WeekFlags &flags) const;
|
||||
|
||||
// the internal representation of the time is the amount of milliseconds
|
||||
// elapsed since the origin which is set by convention to the UNIX/C epoch
|
||||
// value: the midnight of January 1, 1970 (UTC)
|
||||
|
@@ -202,13 +202,13 @@ private:
|
||||
// get the first/last days of the week corresponding to the current style
|
||||
wxDateTime::WeekDay GetWeekStart() const
|
||||
{
|
||||
return HasFlag(wxCAL_MONDAY_FIRST) ? wxDateTime::Mon
|
||||
return WeekStartsOnMonday() ? wxDateTime::Mon
|
||||
: wxDateTime::Sun;
|
||||
}
|
||||
|
||||
wxDateTime::WeekDay GetWeekEnd() const
|
||||
{
|
||||
return HasFlag(wxCAL_MONDAY_FIRST) ? wxDateTime::Sun
|
||||
return WeekStartsOnMonday() ? wxDateTime::Sun
|
||||
: wxDateTime::Sat;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user