mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
kdecore: reimplement KDateTime via QDateTime
KDateTime shall be used only for storing date and time while KLocale shall be used to display such, not even going to test what KDateTime does because it is basically a few methods on top of QDateTime now. and because QDateTime knows not much about calendar systems while KLocale supports several it makes sense for KDateTime to not be used for displaying date and time thus the TODOs for KLocale are simply removed note that KLocale still uses its own parser and formatter which means that the change affects only KDateTime and its uses, not KLocale Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
3795893cdf
commit
f452e2e50b
18 changed files with 405 additions and 8923 deletions
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -190,232 +190,245 @@ QString KDateTimeFormatter::formatDateTimePosix(const KDateTime &fromDateTime,
|
|||
int minWidth = 0;
|
||||
int isoWeekYear = year;
|
||||
QDate yearDate;
|
||||
KDateTime::SpecType timeSpecType;
|
||||
|
||||
//Default settings unless overridden by pad and case flags and width: are 0 pad to 0 width no sign
|
||||
//Names will override 0 pad with no pad unless flagged
|
||||
//Numbers will override with correct width unless flagged
|
||||
QChar thisChar = toFormat.at(formatIndex).unicode();
|
||||
switch (thisChar.unicode()) {
|
||||
case '%': //Literal %
|
||||
if (modifierChar != QLatin1Char(':')) { // E and O mods are ignored if not used, but : is treated as literal
|
||||
componentString = QLatin1Char('%');
|
||||
if (!escapePad) {
|
||||
padChar = QChar();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 't': //Tab
|
||||
if (modifierChar != QLatin1Char(':')) {
|
||||
componentString = QString::fromLatin1("\t");
|
||||
if (!escapePad) {
|
||||
padChar = QChar();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'Y':
|
||||
if (modifierChar == QLatin1Char('E')) { //Era Year, default no pad to 0 places no sign
|
||||
if (!escapePad) {
|
||||
padChar = QLatin1Char(' ');
|
||||
}
|
||||
componentString = calendar->eraYear(fromDateTime.date());
|
||||
} else if (modifierChar != QLatin1Char(':')) { //Long year numeric, default 0 pad to 4 places with sign
|
||||
componentInteger = qAbs(year);
|
||||
minWidth = 4;
|
||||
if (year < 0) {
|
||||
signChar = QLatin1Char('-');
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'C':
|
||||
if (modifierChar == QLatin1Char('E')) { //Era name, default no pad to 0 places no sign
|
||||
if (!escapePad) {
|
||||
padChar = QLatin1Char(' ');
|
||||
}
|
||||
componentString = calendar->eraName(fromDateTime.date());
|
||||
} else if (modifierChar != QLatin1Char(':')) { //Century numeric, default 0 pad to 2 places with sign
|
||||
componentInteger = qAbs(year) / 100 ;
|
||||
minWidth = 2;
|
||||
if (year < 0) {
|
||||
signChar = QLatin1Char('-');
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'y':
|
||||
if (modifierChar == QLatin1Char('E')) { //Year in Era number, default 0 pad to 1 places no sign
|
||||
componentInteger = calendar->yearInEra(fromDateTime.date());
|
||||
minWidth = 1;
|
||||
} else if (modifierChar != QLatin1Char(':')) { //Short year numeric, default 0 pad to 2 places with sign
|
||||
componentInteger = qAbs(year) % 100;
|
||||
minWidth = 2;
|
||||
if (year < 0) {
|
||||
signChar = QLatin1Char('-');
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'm': // Month numeric
|
||||
componentInteger = month;
|
||||
if (modifierChar == QLatin1Char(':')) { //Short month numeric, default no pad to 1 places no sign
|
||||
minWidth = 1;
|
||||
if (!escapePad) {
|
||||
padChar = QChar();
|
||||
}
|
||||
invalidModifier = false;
|
||||
} else { //Long month numeric, default 0 pad to 2 places no sign
|
||||
componentInteger = month;
|
||||
minWidth = 2;
|
||||
}
|
||||
break;
|
||||
case 'n':
|
||||
//PosixFormat %n is newline
|
||||
//KdeFormat %n is short month numeric
|
||||
if (modifierChar != QLatin1Char(':')) {
|
||||
if (formatStandard == KLocale::KdeFormat) {
|
||||
//Copy what %e does, no padding by default
|
||||
//Short month numeric, default no pad to 1 places no sign
|
||||
componentInteger = month;
|
||||
minWidth = 1;
|
||||
case '%': { //Literal %
|
||||
if (modifierChar != QLatin1Char(':')) { // E and O mods are ignored if not used, but : is treated as literal
|
||||
componentString = QLatin1Char('%');
|
||||
if (!escapePad) {
|
||||
padChar = QChar();
|
||||
}
|
||||
} else { // formatStandard == KLocale::PosixFormat
|
||||
componentString = QLatin1Char('\n');
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'd': //Long day numeric, default 0 pad to 2 places no sign
|
||||
if (modifierChar != QLatin1Char(':')) {
|
||||
componentInteger = day;
|
||||
minWidth = 2;
|
||||
}
|
||||
break;
|
||||
case 'e': //Short day numeric, default no sign
|
||||
//PosixFormat %e is space pad to 2 places
|
||||
//KdeFormat %e is no pad to 1 place
|
||||
if (modifierChar != QLatin1Char(':')) {
|
||||
componentInteger = day;
|
||||
if (formatStandard == KLocale::KdeFormat) {
|
||||
minWidth = 1;
|
||||
case 't': { //Tab
|
||||
if (modifierChar != QLatin1Char(':')) {
|
||||
componentString = QString::fromLatin1("\t");
|
||||
if (!escapePad) {
|
||||
padChar = QChar();
|
||||
}
|
||||
} else { // formatStandard == KLocale::PosixFormat
|
||||
minWidth = 2;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'Y': {
|
||||
if (modifierChar == QLatin1Char('E')) { //Era Year, default no pad to 0 places no sign
|
||||
if (!escapePad) {
|
||||
padChar = QLatin1Char(' ');
|
||||
}
|
||||
componentString = calendar->eraYear(fromDateTime.date());
|
||||
} else if (modifierChar != QLatin1Char(':')) { //Long year numeric, default 0 pad to 4 places with sign
|
||||
componentInteger = qAbs(year);
|
||||
minWidth = 4;
|
||||
if (year < 0) {
|
||||
signChar = QLatin1Char('-');
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'B': //Long month name, default space pad to 0 places no sign
|
||||
if (locale->dateMonthNamePossessive()) {
|
||||
case 'C': {
|
||||
if (modifierChar == QLatin1Char('E')) { //Era name, default no pad to 0 places no sign
|
||||
if (!escapePad) {
|
||||
padChar = QLatin1Char(' ');
|
||||
}
|
||||
componentString = calendar->eraName(fromDateTime.date());
|
||||
} else if (modifierChar != QLatin1Char(':')) { //Century numeric, default 0 pad to 2 places with sign
|
||||
componentInteger = qAbs(year) / 100 ;
|
||||
minWidth = 2;
|
||||
if (year < 0) {
|
||||
signChar = QLatin1Char('-');
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'y': {
|
||||
if (modifierChar == QLatin1Char('E')) { //Year in Era number, default 0 pad to 1 places no sign
|
||||
componentInteger = calendar->yearInEra(fromDateTime.date());
|
||||
minWidth = 1;
|
||||
} else if (modifierChar != QLatin1Char(':')) { //Short year numeric, default 0 pad to 2 places with sign
|
||||
componentInteger = qAbs(year) % 100;
|
||||
minWidth = 2;
|
||||
if (year < 0) {
|
||||
signChar = QLatin1Char('-');
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'm': { // Month numeric
|
||||
componentInteger = month;
|
||||
if (modifierChar == QLatin1Char(':')) { //Short month numeric, default no pad to 1 places no sign
|
||||
minWidth = 1;
|
||||
if (!escapePad) {
|
||||
padChar = QChar();
|
||||
}
|
||||
invalidModifier = false;
|
||||
} else { //Long month numeric, default 0 pad to 2 places no sign
|
||||
componentInteger = month;
|
||||
minWidth = 2;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'n': {
|
||||
//PosixFormat %n is newline
|
||||
//KdeFormat %n is short month numeric
|
||||
if (modifierChar != QLatin1Char(':')) {
|
||||
if (formatStandard == KLocale::KdeFormat) {
|
||||
//Copy what %e does, no padding by default
|
||||
//Short month numeric, default no pad to 1 places no sign
|
||||
componentInteger = month;
|
||||
minWidth = 1;
|
||||
if (!escapePad) {
|
||||
padChar = QChar();
|
||||
}
|
||||
} else { // formatStandard == KLocale::PosixFormat
|
||||
componentString = QLatin1Char('\n');
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'd': { //Long day numeric, default 0 pad to 2 places no sign
|
||||
if (modifierChar != QLatin1Char(':')) {
|
||||
componentInteger = day;
|
||||
minWidth = 2;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'e': { //Short day numeric, default no sign
|
||||
//PosixFormat %e is space pad to 2 places
|
||||
//KdeFormat %e is no pad to 1 place
|
||||
if (modifierChar != QLatin1Char(':')) {
|
||||
componentInteger = day;
|
||||
if (formatStandard == KLocale::KdeFormat) {
|
||||
minWidth = 1;
|
||||
if (!escapePad) {
|
||||
padChar = QChar();
|
||||
}
|
||||
} else { // formatStandard == KLocale::PosixFormat
|
||||
minWidth = 2;
|
||||
if (!escapePad) {
|
||||
padChar = QLatin1Char(' ');
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'B': { //Long month name, default space pad to 0 places no sign
|
||||
if (locale->dateMonthNamePossessive()) {
|
||||
if (modifierChar == QLatin1Char(':')) {
|
||||
invalidModifier = false;
|
||||
initEnglish(calendar, locale);
|
||||
componentString = m_englishCalendar->monthName(month, year, KCalendarSystem::LongNamePossessive);
|
||||
} else {
|
||||
componentString = calendar->monthName(month, year, KCalendarSystem::LongNamePossessive);
|
||||
}
|
||||
} else {
|
||||
if (modifierChar == QLatin1Char(':')) {
|
||||
invalidModifier = false;
|
||||
initEnglish(calendar, locale);
|
||||
componentString = m_englishCalendar->monthName(month, year, KCalendarSystem::LongName);
|
||||
} else {
|
||||
componentString = calendar->monthName(month, year, KCalendarSystem::LongName);
|
||||
}
|
||||
}
|
||||
if (!escapePad) {
|
||||
padChar = QLatin1Char(' ');
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'h': //Short month name, default space pad to 0 places no sign
|
||||
case 'b': { //Short month name, default space pad to 0 places no sign
|
||||
if (locale->dateMonthNamePossessive()) {
|
||||
if (modifierChar == QLatin1Char(':')) {
|
||||
invalidModifier = false;
|
||||
initEnglish(calendar, locale);
|
||||
componentString = m_englishCalendar->monthName(month, year, KCalendarSystem::ShortNamePossessive);
|
||||
} else {
|
||||
componentString = calendar->monthName(month, year, KCalendarSystem::ShortNamePossessive);
|
||||
}
|
||||
} else {
|
||||
if (modifierChar == QLatin1Char(':')) {
|
||||
invalidModifier = false;
|
||||
initEnglish(calendar, locale);
|
||||
componentString = m_englishCalendar->monthName(month, year, KCalendarSystem::ShortName);
|
||||
} else {
|
||||
componentString = calendar->monthName(month, year, KCalendarSystem::ShortName);
|
||||
}
|
||||
}
|
||||
if (!escapePad) {
|
||||
padChar = QLatin1Char(' ');
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'A': { //Long weekday name, default space pad to 0 places no sign
|
||||
if (modifierChar == QLatin1Char(':')) {
|
||||
invalidModifier = false;
|
||||
initEnglish(calendar, locale);
|
||||
componentString = m_englishCalendar->monthName(month, year, KCalendarSystem::LongNamePossessive);
|
||||
componentString = m_englishCalendar->weekDayName(fromDateTime.date(), KCalendarSystem::LongDayName);
|
||||
} else {
|
||||
componentString = calendar->monthName(month, year, KCalendarSystem::LongNamePossessive);
|
||||
componentString = calendar->weekDayName(fromDateTime.date(), KCalendarSystem::LongDayName);
|
||||
}
|
||||
} else {
|
||||
if (!escapePad) {
|
||||
padChar = QLatin1Char(' ');
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'a': { //Short weekday name, default space pad to 0 places no sign
|
||||
if (modifierChar == QLatin1Char(':')) {
|
||||
invalidModifier = false;
|
||||
initEnglish(calendar, locale);
|
||||
componentString = m_englishCalendar->monthName(month, year, KCalendarSystem::LongName);
|
||||
componentString = m_englishCalendar->weekDayName(fromDateTime.date(), KCalendarSystem::ShortDayName);
|
||||
} else {
|
||||
componentString = calendar->monthName(month, year, KCalendarSystem::LongName);
|
||||
componentString = calendar->weekDayName(fromDateTime.date(), KCalendarSystem::ShortDayName);
|
||||
}
|
||||
if (!escapePad) {
|
||||
padChar = QLatin1Char(' ');
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (!escapePad) {
|
||||
padChar = QLatin1Char(' ');
|
||||
case 'j': { //Long day of year numeric, default 0 pad to 3 places no sign
|
||||
if (modifierChar != QLatin1Char(':')) {
|
||||
componentInteger = calendar->dayOfYear(fromDateTime.date());
|
||||
minWidth = 3;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'h': //Short month name, default space pad to 0 places no sign
|
||||
case 'b': //Short month name, default space pad to 0 places no sign
|
||||
if (locale->dateMonthNamePossessive()) {
|
||||
if (modifierChar == QLatin1Char(':')) {
|
||||
case 'V': { //Long ISO week of year numeric, default 0 pad to 2 places no sign
|
||||
if (modifierChar != QLatin1Char(':')) {
|
||||
componentInteger = calendar->week(fromDateTime.date(), KLocale::IsoWeekNumber);
|
||||
minWidth = 2;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'G': { //Long year of ISO week of year numeric, default 0 pad to 4 places with sign
|
||||
if (modifierChar != QLatin1Char(':')) {
|
||||
calendar->week(fromDateTime.date(), KLocale::IsoWeekNumber, &isoWeekYear);
|
||||
calendar->setDate(yearDate, isoWeekYear, 1, 1);
|
||||
componentInteger = qAbs(isoWeekYear);
|
||||
minWidth = 4;
|
||||
if (isoWeekYear < 0) {
|
||||
signChar = QLatin1Char('-');
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'g': { //Short year of ISO week of year numeric, default 0 pad to 2 places with sign
|
||||
if (modifierChar != QLatin1Char(':')) {
|
||||
calendar->week(fromDateTime.date(), KLocale::IsoWeekNumber, &isoWeekYear);
|
||||
calendar->setDate(yearDate, isoWeekYear, 1, 1);
|
||||
componentInteger = qAbs(isoWeekYear) % 100;
|
||||
minWidth = 2;
|
||||
if (isoWeekYear < 0) {
|
||||
signChar = QLatin1Char('-');
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'u': {
|
||||
if (modifierChar == QLatin1Char(':')) { // TZ UTC offset hours
|
||||
invalidModifier = false;
|
||||
initEnglish(calendar, locale);
|
||||
componentString = m_englishCalendar->monthName(month, year, KCalendarSystem::ShortNamePossessive);
|
||||
} else {
|
||||
componentString = calendar->monthName(month, year, KCalendarSystem::ShortNamePossessive);
|
||||
}
|
||||
} else {
|
||||
if (modifierChar == QLatin1Char(':')) {
|
||||
invalidModifier = false;
|
||||
initEnglish(calendar, locale);
|
||||
componentString = m_englishCalendar->monthName(month, year, KCalendarSystem::ShortName);
|
||||
} else {
|
||||
componentString = calendar->monthName(month, year, KCalendarSystem::ShortName);
|
||||
}
|
||||
}
|
||||
if (!escapePad) {
|
||||
padChar = QLatin1Char(' ');
|
||||
}
|
||||
break;
|
||||
case 'A': //Long weekday name, default space pad to 0 places no sign
|
||||
if (modifierChar == QLatin1Char(':')) {
|
||||
invalidModifier = false;
|
||||
initEnglish(calendar, locale);
|
||||
componentString = m_englishCalendar->weekDayName(fromDateTime.date(), KCalendarSystem::LongDayName);
|
||||
} else {
|
||||
componentString = calendar->weekDayName(fromDateTime.date(), KCalendarSystem::LongDayName);
|
||||
}
|
||||
if (!escapePad) {
|
||||
padChar = QLatin1Char(' ');
|
||||
}
|
||||
break;
|
||||
case 'a': //Short weekday name, default space pad to 0 places no sign
|
||||
if (modifierChar == QLatin1Char(':')) {
|
||||
invalidModifier = false;
|
||||
initEnglish(calendar, locale);
|
||||
componentString = m_englishCalendar->weekDayName(fromDateTime.date(), KCalendarSystem::ShortDayName);
|
||||
} else {
|
||||
componentString = calendar->weekDayName(fromDateTime.date(), KCalendarSystem::ShortDayName);
|
||||
}
|
||||
if (!escapePad) {
|
||||
padChar = QLatin1Char(' ');
|
||||
}
|
||||
break;
|
||||
case 'j': //Long day of year numeric, default 0 pad to 3 places no sign
|
||||
if (modifierChar != QLatin1Char(':')) {
|
||||
componentInteger = calendar->dayOfYear(fromDateTime.date());
|
||||
minWidth = 3;
|
||||
}
|
||||
break;
|
||||
case 'V': //Long ISO week of year numeric, default 0 pad to 2 places no sign
|
||||
if (modifierChar != QLatin1Char(':')) {
|
||||
componentInteger = calendar->week(fromDateTime.date(), KLocale::IsoWeekNumber);
|
||||
minWidth = 2;
|
||||
}
|
||||
break;
|
||||
case 'G': //Long year of ISO week of year numeric, default 0 pad to 4 places with sign
|
||||
if (modifierChar != QLatin1Char(':')) {
|
||||
calendar->week(fromDateTime.date(), KLocale::IsoWeekNumber, &isoWeekYear);
|
||||
calendar->setDate(yearDate, isoWeekYear, 1, 1);
|
||||
componentInteger = qAbs(isoWeekYear);
|
||||
minWidth = 4;
|
||||
if (isoWeekYear < 0) {
|
||||
signChar = QLatin1Char('-');
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'g': //Short year of ISO week of year numeric, default 0 pad to 2 places with sign
|
||||
if (modifierChar != QLatin1Char(':')) {
|
||||
calendar->week(fromDateTime.date(), KLocale::IsoWeekNumber, &isoWeekYear);
|
||||
calendar->setDate(yearDate, isoWeekYear, 1, 1);
|
||||
componentInteger = qAbs(isoWeekYear) % 100;
|
||||
minWidth = 2;
|
||||
if (isoWeekYear < 0) {
|
||||
signChar = QLatin1Char('-');
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'u':
|
||||
if (modifierChar == QLatin1Char(':')) { // TZ UTC offset hours
|
||||
invalidModifier = false;
|
||||
KDateTime::SpecType timeSpecType = fromDateTime.timeType();
|
||||
if (timeSpecType == KDateTime::UTC || timeSpecType == KDateTime::TimeZone ||
|
||||
timeSpecType == KDateTime::OffsetFromUTC) {
|
||||
componentInteger = fromDateTime.utcOffset() / 3600;
|
||||
if (componentInteger >= 0) {
|
||||
signChar = QLatin1Char('+');
|
||||
|
@ -424,119 +437,125 @@ QString KDateTimeFormatter::formatDateTimePosix(const KDateTime &fromDateTime,
|
|||
signChar = QLatin1Char('-');
|
||||
}
|
||||
minWidth = 2;
|
||||
} else { // Short day of week numeric
|
||||
componentInteger = calendar->dayOfWeek(fromDateTime.date());
|
||||
minWidth = 1;
|
||||
}
|
||||
} else { // Short day of week numeric
|
||||
componentInteger = calendar->dayOfWeek(fromDateTime.date());
|
||||
minWidth = 1;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'D': // US short date format, ignore any overrides
|
||||
if (modifierChar != QLatin1Char(':')) {
|
||||
componentString = formatDateTimePosix(fromDateTime, QString::fromLatin1("%m/%d/%y"), timeOptions, calendar, locale, digitSet, formatStandard);
|
||||
padWidth = 0;
|
||||
padChar = QChar();
|
||||
caseChar = QChar();
|
||||
}
|
||||
break;
|
||||
case 'F': // Full or ISO short date format, ignore any overrides
|
||||
if (modifierChar != QLatin1Char(':')) {
|
||||
componentString = formatDateTimePosix(fromDateTime, QString::fromLatin1("%Y-%m-%d"), timeOptions, calendar, locale, digitSet, formatStandard);
|
||||
padWidth = 0;
|
||||
padChar = QChar();
|
||||
caseChar = QChar();
|
||||
}
|
||||
break;
|
||||
case 'x': // Locale short date format, ignore any overrides
|
||||
if (modifierChar != QLatin1Char(':')) {
|
||||
componentString = formatDateTimePosix(fromDateTime, locale->dateFormatShort(), timeOptions, calendar, locale, digitSet, formatStandard);
|
||||
padWidth = 0;
|
||||
padChar = QChar();
|
||||
caseChar = QChar();
|
||||
}
|
||||
break;
|
||||
case 'H': // Long 24 hour
|
||||
case 'k': // Short 24 hour
|
||||
if (modifierChar != QLatin1Char(':')) {
|
||||
componentInteger = fromDateTime.time().hour();
|
||||
minWidth = 1;
|
||||
if (!escapePad) {
|
||||
case 'D': { // US short date format, ignore any overrides
|
||||
if (modifierChar != QLatin1Char(':')) {
|
||||
componentString = formatDateTimePosix(fromDateTime, QString::fromLatin1("%m/%d/%y"), timeOptions, calendar, locale, digitSet, formatStandard);
|
||||
padWidth = 0;
|
||||
padChar = QChar();
|
||||
caseChar = QChar();
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'I': // Long 12 hour
|
||||
case 'l': // Short 12 hour
|
||||
if (modifierChar != QLatin1Char(':')) {
|
||||
if ((timeOptions & KLocale::TimeDuration) == KLocale::TimeDuration) {
|
||||
componentInteger = fromDateTime.time().hour();
|
||||
} else {
|
||||
componentInteger = locale->d->dayPeriodForTime(fromDateTime.time()).hourInPeriod(fromDateTime.time());
|
||||
case 'F': { // Full or ISO short date format, ignore any overrides
|
||||
if (modifierChar != QLatin1Char(':')) {
|
||||
componentString = formatDateTimePosix(fromDateTime, QString::fromLatin1("%Y-%m-%d"), timeOptions, calendar, locale, digitSet, formatStandard);
|
||||
padWidth = 0;
|
||||
padChar = QChar();
|
||||
caseChar = QChar();
|
||||
}
|
||||
if (thisChar == QLatin1Char('I')) {
|
||||
minWidth = 2;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
case 'x': { // Locale short date format, ignore any overrides
|
||||
if (modifierChar != QLatin1Char(':')) {
|
||||
componentString = formatDateTimePosix(fromDateTime, locale->dateFormatShort(), timeOptions, calendar, locale, digitSet, formatStandard);
|
||||
padWidth = 0;
|
||||
padChar = QChar();
|
||||
caseChar = QChar();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'H': // Long 24 hour
|
||||
case 'k': { // Short 24 hour
|
||||
if (modifierChar != QLatin1Char(':')) {
|
||||
componentInteger = fromDateTime.time().hour();
|
||||
minWidth = 1;
|
||||
if (!escapePad) {
|
||||
padChar = QChar();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'M': // Long minutes
|
||||
if (modifierChar != QLatin1Char(':')) {
|
||||
componentInteger = fromDateTime.time().minute();
|
||||
minWidth = 2;
|
||||
}
|
||||
break;
|
||||
case 'S': // Long seconds
|
||||
invalidModifier = false;
|
||||
if ((timeOptions & KLocale::TimeWithoutSeconds) == KLocale::TimeWithoutSeconds) {
|
||||
//TODO strip the preceding/following punctuation
|
||||
} else {
|
||||
componentInteger = fromDateTime.time().second();
|
||||
if (modifierChar == QLatin1Char(':')) { // Only if not 00 seconds
|
||||
if (componentInteger > 0 || fromDateTime.time().msec() > 0) {
|
||||
result.append(QLatin1Char(':'));
|
||||
minWidth = 2;
|
||||
case 'I': // Long 12 hour
|
||||
case 'l': { // Short 12 hour
|
||||
if (modifierChar != QLatin1Char(':')) {
|
||||
if ((timeOptions & KLocale::TimeDuration) == KLocale::TimeDuration) {
|
||||
componentInteger = fromDateTime.time().hour();
|
||||
} else {
|
||||
componentInteger = locale->d->dayPeriodForTime(fromDateTime.time()).hourInPeriod(fromDateTime.time());
|
||||
}
|
||||
} else {
|
||||
if (thisChar == QLatin1Char('I')) {
|
||||
minWidth = 2;
|
||||
} else {
|
||||
minWidth = 1;
|
||||
if (!escapePad) {
|
||||
padChar = QChar();
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'M': { // Long minutes
|
||||
if (modifierChar != QLatin1Char(':')) {
|
||||
componentInteger = fromDateTime.time().minute();
|
||||
minWidth = 2;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 's':
|
||||
if (modifierChar == QLatin1Char(':')) { // Milliseconds
|
||||
case 'S': { // Long seconds
|
||||
invalidModifier = false;
|
||||
componentInteger = fromDateTime.time().msec();
|
||||
minWidth = 3;
|
||||
} else { // Whole seconds since Unix Epoch
|
||||
KDateTime unixEpoch;
|
||||
unixEpoch.setTime_t(0);
|
||||
componentInteger = unixEpoch.secsTo(fromDateTime);
|
||||
}
|
||||
break;
|
||||
case 'p': // AM/PM symbol
|
||||
case 'P': // AM/PM symbol in lowercase
|
||||
if ((timeOptions & KLocale::TimeWithoutAmPm) == KLocale::TimeWithoutAmPm) {
|
||||
//TODO strip the preceding/following punctuation
|
||||
} else {
|
||||
if (modifierChar == QLatin1Char(':')) {
|
||||
invalidModifier = false;
|
||||
initEnglish(calendar, locale);
|
||||
componentString = m_englishLocale->d->dayPeriodForTime(fromDateTime.time()).periodName(KLocale::ShortName);
|
||||
if ((timeOptions & KLocale::TimeWithoutSeconds) == KLocale::TimeWithoutSeconds) {
|
||||
//TODO strip the preceding/following punctuation
|
||||
} else {
|
||||
componentString = locale->d->dayPeriodForTime(fromDateTime.time()).periodName(KLocale::ShortName);
|
||||
}
|
||||
if (thisChar == QLatin1Char('P')) {
|
||||
componentString = componentString.toLower();
|
||||
componentInteger = fromDateTime.time().second();
|
||||
if (modifierChar == QLatin1Char(':')) { // Only if not 00 seconds
|
||||
if (componentInteger > 0 || fromDateTime.time().msec() > 0) {
|
||||
result.append(QLatin1Char(':'));
|
||||
minWidth = 2;
|
||||
}
|
||||
} else {
|
||||
minWidth = 2;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'z': // TZ UTC Offset
|
||||
invalidModifier = false;
|
||||
timeSpecType = fromDateTime.timeType();
|
||||
if (timeSpecType == KDateTime::UTC || timeSpecType == KDateTime::TimeZone ||
|
||||
timeSpecType == KDateTime::OffsetFromUTC) {
|
||||
case 's': {
|
||||
if (modifierChar == QLatin1Char(':')) { // Milliseconds
|
||||
invalidModifier = false;
|
||||
componentInteger = fromDateTime.time().msec();
|
||||
minWidth = 3;
|
||||
} else { // Whole seconds since Unix Epoch
|
||||
KDateTime unixEpoch;
|
||||
unixEpoch.setTime_t(0);
|
||||
componentInteger = unixEpoch.secsTo(fromDateTime);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'p': // AM/PM symbol
|
||||
case 'P': { // AM/PM symbol in lowercase
|
||||
if ((timeOptions & KLocale::TimeWithoutAmPm) == KLocale::TimeWithoutAmPm) {
|
||||
//TODO strip the preceding/following punctuation
|
||||
} else {
|
||||
if (modifierChar == QLatin1Char(':')) {
|
||||
invalidModifier = false;
|
||||
initEnglish(calendar, locale);
|
||||
componentString = m_englishLocale->d->dayPeriodForTime(fromDateTime.time()).periodName(KLocale::ShortName);
|
||||
} else {
|
||||
componentString = locale->d->dayPeriodForTime(fromDateTime.time()).periodName(KLocale::ShortName);
|
||||
}
|
||||
if (thisChar == QLatin1Char('P')) {
|
||||
componentString = componentString.toLower();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'z': { // TZ UTC Offset
|
||||
invalidModifier = false;
|
||||
if (modifierChar == QLatin1Char(':')) { // TZ UTC offset hours & minutes with colon
|
||||
int offsetInSeconds = fromDateTime.utcOffset();
|
||||
if (offsetInSeconds >= 0) {
|
||||
|
@ -564,25 +583,27 @@ QString KDateTimeFormatter::formatDateTimePosix(const KDateTime &fromDateTime,
|
|||
}
|
||||
minWidth = 4;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'Z': // TZ Name
|
||||
invalidModifier = false;
|
||||
timeSpecType = fromDateTime.timeType();
|
||||
if (timeSpecType == KDateTime::UTC || timeSpecType == KDateTime::TimeZone) {
|
||||
KTimeZone tz = fromDateTime.timeZone();
|
||||
if (tz.isValid()) {
|
||||
if (modifierChar == QLatin1Char(':')) { // TZ full name
|
||||
componentString = QString::fromLatin1(tz.abbreviation(fromDateTime.toUtc().dateTime()));
|
||||
} else { // TZ abbreviated name
|
||||
componentString = tz.name();
|
||||
case 'Z': { // TZ Name
|
||||
invalidModifier = false;
|
||||
Qt::TimeSpec timeSpecType = fromDateTime.timeSpec();
|
||||
if (timeSpecType == Qt::UTC || timeSpecType == Qt::LocalTime) {
|
||||
KTimeZone tz = fromDateTime.timeZone();
|
||||
if (tz.isValid()) {
|
||||
if (modifierChar == QLatin1Char(':')) { // TZ full name
|
||||
componentString = QString::fromLatin1(tz.abbreviation(fromDateTime.toUTC()));
|
||||
} else { // TZ abbreviated name
|
||||
componentString = tz.name();
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: { //No valid format code, treat as literal
|
||||
invalidComponent = true;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default: //No valid format code, treat as literal
|
||||
invalidComponent = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (invalidComponent || invalidModifier) { // If escape sequence invalid treat as literal
|
||||
|
|
|
@ -636,10 +636,7 @@ QDebug KDebug(const QtMsgType type, const char* const funcinfo, const int area)
|
|||
|
||||
QDebug operator<<(QDebug s, const KDateTime &time)
|
||||
{
|
||||
if ( time.isDateOnly() )
|
||||
s.nospace() << "KDateTime(" << qPrintable(time.toString(KDateTime::QtTextDate)) << ")";
|
||||
else
|
||||
s.nospace() << "KDateTime(" << qPrintable(time.toString(KDateTime::ISODate)) << ")";
|
||||
s.nospace() << "KDateTime(" << time.toString() << ")";
|
||||
return s.space();
|
||||
}
|
||||
|
||||
|
|
|
@ -565,7 +565,6 @@ public:
|
|||
*/
|
||||
KDECORE_DEPRECATED bool nounDeclension() const;
|
||||
|
||||
//KDE5 move to KDateTime namespace
|
||||
/**
|
||||
* @since 4.6
|
||||
*
|
||||
|
@ -600,7 +599,6 @@ public:
|
|||
ThaiCalendar = 23 /**< Thai Calendar, aka Buddhist or Thai Buddhist */
|
||||
};
|
||||
|
||||
//KDE5 move to KDateTime namespace
|
||||
/**
|
||||
* @since 4.6
|
||||
*
|
||||
|
@ -617,7 +615,6 @@ public:
|
|||
SimpleWeek = 3 /**< Week 1 starts Jan 1st ends after 7 days */
|
||||
};
|
||||
|
||||
//KDE5 move to KDateTime namespace
|
||||
/**
|
||||
* @since 4.4
|
||||
*
|
||||
|
@ -629,7 +626,6 @@ public:
|
|||
UnicodeFormat /**< UNICODE Standard (Qt/Java/OSX/Windows) */
|
||||
};
|
||||
|
||||
//KDE5 move to KDateTime namespace
|
||||
/**
|
||||
* @since 4.6
|
||||
*
|
||||
|
@ -647,7 +643,6 @@ public:
|
|||
//StrictParsing /**< Parse Date/Time strictly to the format. */
|
||||
};
|
||||
|
||||
//KDE5 move to KDateTime namespace
|
||||
/**
|
||||
* @since 4.6
|
||||
*
|
||||
|
@ -693,7 +688,6 @@ public:
|
|||
};
|
||||
Q_DECLARE_FLAGS(DateTimeComponents, DateTimeComponent)
|
||||
|
||||
//KDE5 move to KDateTime namespace
|
||||
/**
|
||||
* @since 4.6
|
||||
*
|
||||
|
@ -712,7 +706,6 @@ public:
|
|||
LongName /**< Long text format, e.g. Monday for Monday */
|
||||
};
|
||||
|
||||
//KDE5 move to KDateTime namespace
|
||||
/**
|
||||
* Format for date string.
|
||||
*/
|
||||
|
@ -730,7 +723,6 @@ public:
|
|||
IsoOrdinalDate /**< ISO-8601 Ordinal Date format YYYY-DDD, e.g. 2009-001 */
|
||||
};
|
||||
|
||||
//KDE5 move to KDateTime namespace
|
||||
/**
|
||||
* Returns a string formatted to the current locale's conventions
|
||||
* regarding dates.
|
||||
|
@ -742,7 +734,6 @@ public:
|
|||
*/
|
||||
QString formatDate(const QDate &date, DateFormat format = LongDate) const;
|
||||
|
||||
//KDE5 move to KDateTime namespace
|
||||
/**
|
||||
* Returns a string formatted to the current locale's conventions
|
||||
* regarding both date and time.
|
||||
|
@ -757,7 +748,6 @@ public:
|
|||
QString formatDateTime(const QDateTime &dateTime, DateFormat format = ShortDate,
|
||||
bool includeSecs = false) const;
|
||||
|
||||
//KDE5 move to KDateTime namespace
|
||||
/**
|
||||
* Options for formatting date-time values.
|
||||
*/
|
||||
|
@ -767,7 +757,6 @@ public:
|
|||
};
|
||||
Q_DECLARE_FLAGS(DateTimeFormatOptions, DateTimeFormatOption)
|
||||
|
||||
//KDE5 move to KDateTime namespace
|
||||
/**
|
||||
* Returns a string formatted to the current locale's conventions
|
||||
* regarding both date and time.
|
||||
|
@ -805,7 +794,6 @@ public:
|
|||
*/
|
||||
QString formatTime(const QTime &pTime, bool includeSecs = false, bool isDuration = false) const;
|
||||
|
||||
//KDE5 move to KDateTime namespace
|
||||
/**
|
||||
* @since 4.4
|
||||
*
|
||||
|
@ -832,7 +820,6 @@ public:
|
|||
};
|
||||
Q_DECLARE_FLAGS(TimeFormatOptions, TimeFormatOption)
|
||||
|
||||
//KDE5 move to KDateTime namespace
|
||||
/**
|
||||
* @since 4.4
|
||||
*
|
||||
|
@ -913,7 +900,6 @@ public:
|
|||
*/
|
||||
const KCalendarSystem * calendar() const;
|
||||
|
||||
//KDE5 remove
|
||||
/**
|
||||
* @deprecated use calendarSystem() instead
|
||||
*
|
||||
|
@ -936,7 +922,6 @@ public:
|
|||
*/
|
||||
KLocale::CalendarSystem calendarSystem() const;
|
||||
|
||||
//KDE5 remove
|
||||
/**
|
||||
* @deprecated use setCalendarSystem() instead
|
||||
*
|
||||
|
@ -992,7 +977,6 @@ public:
|
|||
*/
|
||||
double readNumber(const QString &numStr, bool * ok = 0) const;
|
||||
|
||||
//KDE5 move to KDateTime namespace
|
||||
/**
|
||||
* Converts a localized date string to a QDate. This method will try all
|
||||
* ReadDateFlag formats in preferred order to read a valid date.
|
||||
|
@ -1008,7 +992,6 @@ public:
|
|||
*/
|
||||
QDate readDate(const QString &str, bool* ok = 0) const;
|
||||
|
||||
//KDE5 move to KDateTime namespace
|
||||
/**
|
||||
* Converts a localized date string to a QDate, using the specified format.
|
||||
* You will usually not want to use this method.
|
||||
|
@ -1016,7 +999,6 @@ public:
|
|||
*/
|
||||
QDate readDate(const QString &intstr, const QString &fmt, bool* ok = 0) const;
|
||||
|
||||
//KDE5 move to KDateTime namespace
|
||||
/**
|
||||
* Flags for readDate()
|
||||
*/
|
||||
|
@ -1033,7 +1015,6 @@ public:
|
|||
ISO Week date format (YYYY-DDD) */
|
||||
};
|
||||
|
||||
//KDE5 move to KDateTime namespace
|
||||
/**
|
||||
* Converts a localized date string to a QDate.
|
||||
* This method is stricter than readDate(str,&ok): it will only accept
|
||||
|
|
|
@ -2184,35 +2184,10 @@ QString KLocalePrivate::formatDateTime(const QDateTime &dateTime, KLocale::DateF
|
|||
QString KLocalePrivate::formatDateTime(const KDateTime &dateTime, KLocale::DateFormat format,
|
||||
KLocale::DateTimeFormatOptions options)
|
||||
{
|
||||
QString dt;
|
||||
|
||||
if (dateTime.isDateOnly()) {
|
||||
dt = formatDate(dateTime.date(), format);
|
||||
} else {
|
||||
KDateTime now = KDateTime::currentDateTime(dateTime.timeSpec());
|
||||
int daysTo = dateTime.date().daysTo(now.date());
|
||||
int secsTo = now.secsTo(dateTime);
|
||||
dt = KLocalePrivate::formatDateTime(q, dateTime.dateTime(), format, (options & KLocale::Seconds), daysTo, secsTo);
|
||||
}
|
||||
|
||||
if (options & KLocale::TimeZone) {
|
||||
QString tz;
|
||||
switch (dateTime.timeType()) {
|
||||
case KDateTime::OffsetFromUTC:
|
||||
tz = i18n(dateTime.toString(QString::fromLatin1("%z")).toUtf8());
|
||||
break;
|
||||
case KDateTime::UTC:
|
||||
case KDateTime::TimeZone:
|
||||
tz = i18n(dateTime.toString(QString::fromLatin1((format == KLocale::ShortDate) ? "%Z" : "%:Z")).toUtf8());
|
||||
break;
|
||||
case KDateTime::ClockTime:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return i18nc("concatenation of date/time and time zone", "%1 %2", dt, tz);
|
||||
}
|
||||
|
||||
return dt;
|
||||
QDateTime now = QDateTime::currentDateTime();
|
||||
int daysTo = dateTime.toLocalTime().date().daysTo(now.date());
|
||||
int secsTo = now.secsTo(dateTime);
|
||||
return KLocalePrivate::formatDateTime(q, dateTime, format, (options & KLocale::Seconds), daysTo, secsTo);
|
||||
}
|
||||
|
||||
bool KLocalePrivate::useDefaultLanguage() const
|
||||
|
|
|
@ -38,7 +38,6 @@ KDECORE_UNIT_TESTS(
|
|||
klockfiletest
|
||||
ktempdirtest
|
||||
ksharedptrtest
|
||||
kdatetimetest
|
||||
ksavefiletest
|
||||
kdesktopfiletest
|
||||
ktemporaryfiletest
|
||||
|
|
|
@ -372,5 +372,5 @@ void KDateTimeFormatterTest::testFormatUnicode()
|
|||
|
||||
void KDateTimeFormatterTest::compareFormatUnicode(KDateTimeFormatter formatter, const KDateTime &testDateTime, const QString &testFormat)
|
||||
{
|
||||
QCOMPARE(formatter.formatDateTime(testDateTime, testFormat, 0, KGlobal::locale()->calendar(), KGlobal::locale(), KGlobal::locale()->dateTimeDigitSet(), KLocale::UnicodeFormat), testDateTime.dateTime().toString(testFormat));
|
||||
QCOMPARE(formatter.formatDateTime(testDateTime, testFormat, 0, KGlobal::locale()->calendar(), KGlobal::locale(), KGlobal::locale()->dateTimeDigitSet(), KLocale::UnicodeFormat), testDateTime.toString(testFormat));
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,61 +0,0 @@
|
|||
/* This file is part of the KDE libraries
|
||||
Copyright (c) 2005,2011 David Jarvie <djarvie@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef KDATETIMETEST_H
|
||||
#define KDATETIMETEST_H
|
||||
|
||||
#include <QtCore/QObject>
|
||||
|
||||
class KDateTimeTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private Q_SLOTS:
|
||||
void initTestCase();
|
||||
void cleanupTestCase();
|
||||
void specConstructors();
|
||||
void specSet();
|
||||
void constructors();
|
||||
void toUtc();
|
||||
void toOffsetFromUtc();
|
||||
void toLocalZone();
|
||||
void toClockTime();
|
||||
void toZone();
|
||||
void toTimeSpec();
|
||||
void set();
|
||||
void equal();
|
||||
void lessThan();
|
||||
void compare();
|
||||
void addSubtract();
|
||||
void addMSecs();
|
||||
void addSubtractDate();
|
||||
void dstShifts();
|
||||
void strings_iso8601();
|
||||
void strings_rfc2822();
|
||||
void strings_rfc3339();
|
||||
void strings_qttextdate();
|
||||
void strings_format();
|
||||
void cache();
|
||||
void stream();
|
||||
void misc();
|
||||
private:
|
||||
void removeDir(const QString &subdir);
|
||||
QString mDataDir;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -389,10 +389,7 @@ KLocaleTest::formatDateTime()
|
|||
qdt = qdt.addDays(-1);
|
||||
QCOMPARE(locale.formatDateTime(qdt, KLocale::FancyLongDate), qdt.toString(full));
|
||||
|
||||
small = "%Y-%m-%d %H:%M";
|
||||
smallsecs = "%Y-%m-%d %H:%M:%S";
|
||||
full = "%A %d %B %Y %H:%M";
|
||||
fullsecs = "%A %d %B %Y %H:%M:%S";
|
||||
full = "dddd dd MMMM yyyy hh:mm";
|
||||
KDateTime kdt;
|
||||
const KTimeZone tz = KSystemTimeZones::zone("Pacific/Fiji");
|
||||
if (!tz.isValid())
|
||||
|
@ -400,14 +397,6 @@ KLocaleTest::formatDateTime()
|
|||
kdt = KDateTime::currentDateTime(tz);
|
||||
today = kdt.date();
|
||||
nowt = kdt.time();
|
||||
QCOMPARE(locale.formatDateTime(kdt), kdt.toString(small));
|
||||
// QCOMPARE(locale.formatDateTime(kdt, KLocale::ShortDate, KLocale::Seconds), kdt.toString(smallsecs));
|
||||
QCOMPARE(locale.formatDateTime(kdt, KLocale::LongDate), kdt.toString(full));
|
||||
// QCOMPARE(locale.formatDateTime(kdt, KLocale::LongDate, KLocale::Seconds), kdt.toString(fullsecs));
|
||||
|
||||
// QCOMPARE(locale.formatDateTime(kdt, KLocale::FancyLongDate), QString("Today") + kdt.time().toString(tfmt));
|
||||
kdt = kdt.addSecs(3605); // more than 1 hour from now
|
||||
QCOMPARE(locale.formatDateTime(kdt, KLocale::FancyLongDate), kdt.toString(full));
|
||||
kdt.setDate(today);
|
||||
kdt.setTime(QTime(0,0,0));
|
||||
QCOMPARE(locale.formatDateTime(kdt, KLocale::FancyLongDate), QString("Today" + kdt.time().toString(tfmt)));
|
||||
|
|
|
@ -70,7 +70,7 @@ void KCupsOptionsJobWidget::setupCupsOptions( QStringList &cupsOptions )
|
|||
//Check if time is for tomorrow in case of DST change overnight
|
||||
if ( jobHoldTime() < localDateTime.time() ) localDateTime.addDays(1);
|
||||
localDateTime.setTime( jobHoldTime() );
|
||||
setCupsOption( cupsOptions, "job-hold-until", localDateTime.toUtc().time().toString("HH:mm") );
|
||||
setCupsOption( cupsOptions, "job-hold-until", localDateTime.toUTC().time().toString("HH:mm") );
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -213,10 +213,6 @@ void KDateTimeEditTest::testTimeSpec()
|
|||
QCOMPARE(m_edit->timeSpec(), KDateTime::currentLocalDateTime().timeSpec());
|
||||
QCOMPARE(m_edit->timeZones(), KSystemTimeZones::zones());
|
||||
|
||||
KDateTime::Spec spec = KDateTime::Spec::OffsetFromUTC(3600);
|
||||
m_edit->setTimeSpec(spec);
|
||||
QCOMPARE(m_edit->timeSpec(), spec);
|
||||
|
||||
KTimeZones::ZoneMap map;
|
||||
map.insert("Africa/Cairo", KSystemTimeZones::zone("Africa/Cairo"));
|
||||
m_edit->setTimeZones(map);
|
||||
|
|
|
@ -223,9 +223,7 @@ void KDateTimeEditPrivate::selectTimeZone(int index)
|
|||
|
||||
void KDateTimeEditPrivate::enterTimeZone(const QString &zone)
|
||||
{
|
||||
q->setTimeSpec(m_zones.value(zone));
|
||||
emit q->dateTimeEntered(m_dateTime);
|
||||
emit q->timeSpecEntered(m_dateTime.timeSpec());
|
||||
q->setDateTime(KDateTime::currentDateTime(m_zones.value(zone)));
|
||||
}
|
||||
|
||||
void KDateTimeEditPrivate::warnDateTime()
|
||||
|
@ -308,7 +306,7 @@ QTime KDateTimeEdit::time() const
|
|||
return d->m_dateTime.time();
|
||||
}
|
||||
|
||||
KDateTime::Spec KDateTimeEdit::timeSpec() const
|
||||
Qt::TimeSpec KDateTimeEdit::timeSpec() const
|
||||
{
|
||||
return d->m_dateTime.timeSpec();
|
||||
}
|
||||
|
@ -428,9 +426,9 @@ void KDateTimeEdit::assignTime(const QTime &time)
|
|||
d->ui.m_timeCombo->setTime(time);
|
||||
}
|
||||
|
||||
void KDateTimeEdit::setTimeSpec(const KDateTime::Spec &spec)
|
||||
void KDateTimeEdit::setTimeSpec(const Qt::TimeSpec spec)
|
||||
{
|
||||
if (spec == d->m_dateTime.timeSpec() || !spec.isValid()) {
|
||||
if (spec == d->m_dateTime.timeSpec()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -439,7 +437,7 @@ void KDateTimeEdit::setTimeSpec(const KDateTime::Spec &spec)
|
|||
emit timeSpecChanged(d->m_dateTime.timeSpec());
|
||||
}
|
||||
|
||||
void KDateTimeEdit::assignTimeSpec(const KDateTime::Spec &spec)
|
||||
void KDateTimeEdit::assignTimeSpec(const Qt::TimeSpec spec)
|
||||
{
|
||||
d->m_dateTime.setTimeSpec(spec);
|
||||
d->updateTimeSpecWidget();
|
||||
|
|
|
@ -134,7 +134,7 @@ public:
|
|||
*
|
||||
* @return the currently selected time spec
|
||||
*/
|
||||
KDateTime::Spec timeSpec() const;
|
||||
Qt::TimeSpec timeSpec() const;
|
||||
|
||||
/**
|
||||
* Returns the list of Calendar Systems displayed.
|
||||
|
@ -367,7 +367,7 @@ Q_SIGNALS:
|
|||
*
|
||||
* @param timeSpec the new time spec
|
||||
*/
|
||||
void timeSpecEntered(const KDateTime::Spec &spec);
|
||||
void timeSpecEntered(const Qt::TimeSpec spec);
|
||||
|
||||
/**
|
||||
* Signal if the time spec has been changed either manually by the user
|
||||
|
@ -375,7 +375,7 @@ Q_SIGNALS:
|
|||
*
|
||||
* @param timeSpec the new time spec
|
||||
*/
|
||||
void timeSpecChanged(const KDateTime::Spec &spec);
|
||||
void timeSpecChanged(const Qt::TimeSpec spec);
|
||||
|
||||
public Q_SLOTS:
|
||||
|
||||
|
@ -430,7 +430,7 @@ public Q_SLOTS:
|
|||
*
|
||||
* @param spec the new spec
|
||||
*/
|
||||
void setTimeSpec(const KDateTime::Spec &spec);
|
||||
void setTimeSpec(const Qt::TimeSpec spec);
|
||||
|
||||
/**
|
||||
* Set the minimum and maximum date and time range
|
||||
|
@ -633,7 +633,7 @@ protected:
|
|||
*
|
||||
* @param spec the new time spec
|
||||
*/
|
||||
void assignTimeSpec(const KDateTime::Spec &spec);
|
||||
void assignTimeSpec(const Qt::TimeSpec spec);
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -231,8 +231,8 @@ bool KDirSortFilterProxyModel::subSortLessThan(const QModelIndex& left,
|
|||
}
|
||||
|
||||
case KDirModel::ModifiedTime: {
|
||||
KDateTime leftModifiedTime = leftFileItem.time(KFileItem::ModificationTime).toLocalZone();
|
||||
KDateTime rightModifiedTime = rightFileItem.time(KFileItem::ModificationTime).toLocalZone();
|
||||
KDateTime leftModifiedTime = leftFileItem.time(KFileItem::ModificationTime).toLocalTime();
|
||||
KDateTime rightModifiedTime = rightFileItem.time(KFileItem::ModificationTime).toLocalTime();
|
||||
|
||||
if (leftModifiedTime == rightModifiedTime) {
|
||||
return d->compare(leftFileItem.text(), rightFileItem.text(), sortCaseSensitivity()) < 0;
|
||||
|
|
|
@ -441,8 +441,8 @@ void FileUndoManagerPrivate::slotResult(KJob *job)
|
|||
time_t mtime = statJob->statResult().numberValue(KIO::UDSEntry::UDS_MODIFICATION_TIME, -1);
|
||||
if (mtime != op.m_mtime) {
|
||||
kDebug() << op.m_dst << " was modified after being copied!";
|
||||
KDateTime srcTime; srcTime.setTime_t(op.m_mtime); srcTime = srcTime.toLocalZone();
|
||||
KDateTime destTime; destTime.setTime_t(mtime); destTime = destTime.toLocalZone();
|
||||
KDateTime srcTime; srcTime.setTime_t(op.m_mtime); srcTime = srcTime.toLocalTime();
|
||||
KDateTime destTime; destTime.setTime_t(mtime); destTime = destTime.toLocalTime();
|
||||
if (!m_uiInterface->copiedFileWasModified(op.m_src, op.m_dst, srcTime, destTime)) {
|
||||
stopUndo(false);
|
||||
}
|
||||
|
|
|
@ -266,7 +266,7 @@ void KFileItemPrivate::init()
|
|||
void KFileItemPrivate::setTime(KFileItem::FileTimes mappedWhich, long long time_t_val) const
|
||||
{
|
||||
m_time[mappedWhich].setTime_t(time_t_val);
|
||||
m_time[mappedWhich] = m_time[mappedWhich].toLocalZone(); // #160979
|
||||
m_time[mappedWhich] = m_time[mappedWhich].toLocalTime(); // #160979
|
||||
}
|
||||
|
||||
KDateTime KFileItemPrivate::time(KFileItem::FileTimes mappedWhich) const
|
||||
|
|
Loading…
Add table
Reference in a new issue