История изменений
Исправление
bhfq,
(текущая версия)
:
Qt::DayOfWeek firstDayOfWeekFromLocale()
{
#if QT_VERSION >= QT_VERSION_CHECK(4, 8, 0)
return QLocale().firstDayOfWeek();
#else
Qt::DayOfWeek firstDay = Qt::Monday;
# ifdef Q_OS_WIN
WCHAR wsDay[4];
# if defined(_WIN32_WINNT_VISTA) && WINVER >= _WIN32_WINNT_VISTA && defined(LOCALE_NAME_USER_DEFAULT)
if (GetLocaleInfoEx(LOCALE_NAME_USER_DEFAULT, LOCALE_IFIRSTDAYOFWEEK, wsDay, 4)) {
# else
if (GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_IFIRSTDAYOFWEEK, wsDay, 4)) {
# endif
bool ok;
int wfd = QString::fromWCharArray(wsDay).toInt(&ok) + 1;
if (ok) {
firstDay = (Qt::DayOfWeek)(unsigned char)wfd;
}
}
# elif defined(__GLIBC__)
firstDay = (Qt::DayOfWeek)(unsigned char)((*nl_langinfo(_NL_TIME_FIRST_WEEKDAY) + 5) % 7 + 1);
# elif defined(Q_OS_MAC)
firstDay = (Qt::DayOfWeek)(unsigned char)macosCommonFirstWeekday();
# endif
return firstDay;
#endif
}
#include "cocoacommon.h" /* int macosCommonFirstWeekday(); */
#include <Cocoa/Cocoa.h>
int macosCommonFirstWeekday() {
int firstDay;
NSCalendar *cal = [NSCalendar currentCalendar];
firstDay = ([cal firstWeekday] + 5) % 7 + 1;
return firstDay;
}
Исправление
bhfq,
:
Qt::DayOfWeek firstDayOfWeekFromLocale()
{
#if QT_VERSION >= QT_VERSION_CHECK(4, 8, 0)
return QLocale().firstDayOfWeek();
#else
Qt::DayOfWeek firstDay = Qt::Monday;
# ifdef Q_OS_WIN
WCHAR wsDay[4];
# if defined(_WIN32_WINNT_VISTA) && WINVER >= _WIN32_WINNT_VISTA && defined(LOCALE_NAME_USER_DEFAULT)
if (GetLocaleInfoEx(LOCALE_NAME_USER_DEFAULT, LOCALE_IFIRSTDAYOFWEEK, wsDay, 4)) {
# else
if (GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_IFIRSTDAYOFWEEK, wsDay, 4)) {
# endif
bool ok;
int wfd = QString::fromWCharArray(wsDay).toInt(&ok) + 1;
if (ok) {
firstDay = (Qt::DayOfWeek)(unsigned char)wfd;
}
}
# elif defined(__GLIBC__)
firstDay = (Qt::DayOfWeek)(unsigned char)((*nl_langinfo(_NL_TIME_FIRST_WEEKDAY) + 5) % 7 + 1);
# elif defined(Q_OS_MAC)
firstDay = (Qt::DayOfWeek)(unsigned char)macosCommonFirstWeekday();
# endif
return firstDay;
#endif
}
#include "cocoacommon.h"
#include <Cocoa/Cocoa.h>
int macosCommonFirstWeekday() {
int firstDay;
NSCalendar *cal = [NSCalendar currentCalendar];
firstDay = ([cal firstWeekday] + 5) % 7 + 1;
return firstDay;
}
Исходная версия
bhfq,
:
Qt::DayOfWeek firstDayOfWeekFromLocale()
{
#if QT_VERSION >= QT_VERSION_CHECK(4, 8, 0)
return QLocale().firstDayOfWeek();
#else
Qt::DayOfWeek firstDay = Qt::Monday;
# ifdef Q_OS_WIN
WCHAR wsDay[4];
# if defined(_WIN32_WINNT_VISTA) && WINVER >= _WIN32_WINNT_VISTA && defined(LOCALE_NAME_USER_DEFAULT)
if (GetLocaleInfoEx(LOCALE_NAME_USER_DEFAULT, LOCALE_IFIRSTDAYOFWEEK, wsDay, 4)) {
# else
if (GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_IFIRSTDAYOFWEEK, wsDay, 4)) {
# endif
bool ok;
int wfd = QString::fromWCharArray(wsDay).toInt(&ok) + 1;
if (ok) {
firstDay = (Qt::DayOfWeek)(unsigned char)wfd;
}
}
# elif defined(__GLIBC__)
firstDay = (Qt::DayOfWeek)(unsigned char)((*nl_langinfo(_NL_TIME_FIRST_WEEKDAY) + 5) % 7 + 1);
# elif defined(Q_OS_MAC)
firstDay = (Qt::DayOfWeek)(unsigned char)macosCommonFirstWeekday();
# endif
return firstDay;
#endif
}
#include "cocoacommon.h"
#include <Cocoa/Cocoa.h>
int macosCommonFirstWeekday() {
int firstDay;
NSCalendar *cal = [NSCalendar currentCalendar];
firstDay = ([cal firstWeekday] + 5) % 7 + 1;
return firstDay;
}