KDECore
kdatetimeformatter.cpp
Go to the documentation of this file.
59 return formatDateTime(KDateTime(fromDate), toFormat, 0, calendar, locale, digitSet, formatStandard);
75 return formatDateTime(KDateTime(QDate::currentDate(), fromTime), toFormat, timeOptions, calendar, locale, digitSet, formatStandard);
95 return formatDateTimePosix(fromDateTime, toFormat, timeOptions, calendar, locale, digitSet, formatStandard);
164 } else if (!escapeMod && !escapeWidth && (thisChar == QLatin1Char('^') || thisChar == QLatin1Char('#'))) { // Change case
170 (escapeWidth && thisChar >= QLatin1Char('0') && thisChar <= QLatin1Char('9')))) { // Change width
178 } else if (!escapeMod && (thisChar == QLatin1Char('E') || thisChar == QLatin1Char('O') || thisChar == QLatin1Char(':'))) { // Set modifier
196 //Default settings unless overridden by pad and case flags and width: are 0 pad to 0 width no sign
202 if (modifierChar != QLatin1Char(':')) { // E and O mods are ignored if not used, but : is treated as literal
223 } else if (modifierChar != QLatin1Char(':')) { //Long year numeric, default 0 pad to 4 places with sign
237 } else if (modifierChar != QLatin1Char(':')) { //Century numeric, default 0 pad to 2 places with sign
249 } else if (modifierChar != QLatin1Char(':')) { //Short year numeric, default 0 pad to 2 places with sign
259 if (modifierChar == QLatin1Char(':')) { //Short month numeric, default no pad to 1 places no sign
316 componentString = m_englishCalendar->monthName(month, year, KCalendarSystem::LongNamePossessive);
339 componentString = m_englishCalendar->monthName(month, year, KCalendarSystem::ShortNamePossessive);
360 componentString = m_englishCalendar->weekDayName(fromDateTime.date(), KCalendarSystem::LongDayName);
372 componentString = m_englishCalendar->weekDayName(fromDateTime.date(), KCalendarSystem::ShortDayName);
436 componentString = formatDateTimePosix(fromDateTime, QString::fromLatin1("%m/%d/%y"), timeOptions, calendar, locale, digitSet, formatStandard);
444 componentString = formatDateTimePosix(fromDateTime, QString::fromLatin1("%Y-%m-%d"), timeOptions, calendar, locale, digitSet, formatStandard);
452 componentString = formatDateTimePosix(fromDateTime, locale->dateFormatShort(), timeOptions, calendar, locale, digitSet, formatStandard);
474 componentInteger = locale->d->dayPeriodForTime(fromDateTime.time()).hourInPeriod(fromDateTime.time());
527 componentString = m_englishLocale->d->dayPeriodForTime(fromDateTime.time()).periodName(KLocale::ShortName);
529 componentString = locale->d->dayPeriodForTime(fromDateTime.time()).periodName(KLocale::ShortName);
552 QString hourComponent = stringFromInteger(offsetHours, 2, QLatin1Char('0'), signChar, digitSet, locale);
553 QString minuteComponent = stringFromInteger(offsetMinutes, 2, QLatin1Char('0'), QChar(), digitSet, locale);
593 componentString = stringFromInteger(componentInteger, padWidth, padChar, signChar, digitSet, locale);
626 void KDateTimeFormatter::initEnglish(const KCalendarSystem *calendar, const KLocale *locale) const
721 result = QString::number(calendar->day(fromDateTime.date())).rightJustified(2, QLatin1Char('0'), true);
727 result = calendar->monthName(calendar->month(fromDateTime.date()), calendar->year(fromDateTime.date()), KCalendarSystem::LongName);
730 result = calendar->monthName(calendar->month(fromDateTime.date()), calendar->year(fromDateTime.date()), KCalendarSystem::ShortName);
733 result = QString::number(calendar->month(fromDateTime.date())).rightJustified(2, QLatin1Char('0'), true);
748 result = QString::number(calendar->year(fromDateTime.date())).right(2).rightJustified(2, QLatin1Char('0'));
756 return result + getUnicodeString(fromDateTime, toFormat.mid(removed), timeOptions, calendar, locale, digitSet);
761 QString KDateTimeFormatter::stringFromInteger(int number, int padWidth, QChar padChar, QChar signChar,
782 if (padChar == QLatin1Char('0')) { // If zero-padded, zero considered part of the number, so pad the number then prepend the sign
784 result = locale->convertDigits(QString::number(number).rightJustified(padWidth, padChar).prepend(signChar), digitSet);
785 } else { // If space-padded space not considered part of the number, so prepend the sign and then pad the number
787 result = locale->convertDigits(QString::number(number).prepend(signChar).rightJustified(padWidth, padChar), digitSet);
791 result = locale->convertDigits(QString::number(number).rightJustified(padWidth, padChar), digitSet);
Long name possessive format, e.g.
Definition: kcalendarsystem.h:59
int minute() const
virtual ~KDateTimeFormatter()
Definition: kdatetimeformatter.cpp:41
QString eraName(const QDate &date, StringFormat format=ShortFormat) const
Definition: kcalendarsystem.cpp:1371
QString & append(QChar ch)
QString toUpper() const
Date/times with associated time zone.
virtual QString formatDateTime(const KDateTime &fromDateTime, const QString &toFormat, KLocale::TimeFormatOptions timeOptions=0, const KCalendarSystem *calendar=KGlobal::locale() ->calendar(), const KLocale *locale=KGlobal::locale(), KLocale::DigitSet digitSet=KGlobal::locale() ->dateTimeDigitSet(), KLocale::DateTimeFormatStandard standard=KLocale::KdeFormat) const
Definition: kdatetimeformatter.cpp:79
virtual QString monthName(int month, int year, MonthNameFormat format=LongName) const =0
Gets specific calendar type month name for a given month number If an invalid month is specified...
Definition: kcalendarsystem.cpp:1842
QString & prepend(QChar ch)
int size() const
bool isValid() const
virtual int day(const QDate &date) const
Returns the day portion of a given date in the current calendar system.
Definition: kcalendarsystem.cpp:1357
static KCalendarSystem * create(const QString &calType=QLatin1String("gregorian"), const KLocale *locale=0)
Definition: kcalendarsystem.cpp:47
int second() const
KCalendarSystem abstract base class, provides support for local Calendar Systems in KDE...
Definition: kcalendarsystem.h:40
QString convertDigits(const QString &str, DigitSet digitSet, bool ignoreContext=false) const
Definition: klocale.cpp:212
virtual QString formatTime(const QTime &fromTime, const QString &toFormat, KLocale::TimeFormatOptions timeOptions=0, const KCalendarSystem *calendar=KGlobal::locale() ->calendar(), const KLocale *locale=KGlobal::locale(), KLocale::DigitSet digitSet=KGlobal::locale() ->dateTimeDigitSet(), KLocale::DateTimeFormatStandard standard=KLocale::KdeFormat) const
Definition: kdatetimeformatter.cpp:62
void clear()
void setTime_t(qint64 seconds)
Sets the time to a UTC time, specified as seconds since 00:00:00 UTC 1st January 1970 (as returned by...
Definition: kdatetime.cpp:1009
QString dateFormatShort() const
Returns the currently selected short date format.
Definition: klocale.cpp:515
QString number(int n, int base)
int utcOffset() const
Returns the UTC offset associated with the date/time.
Definition: kdatetime.cpp:858
virtual int dayOfYear(const QDate &date) const
Returns the day number of year for the given date.
Definition: kcalendarsystem.cpp:1675
bool setLanguage(const QString &language, KConfig *config)
Changes the current language.
Definition: klocale.cpp:85
QString rightJustified(int width, QChar fill, bool truncate) const
QByteArray abbreviation(const QDateTime &utcDateTime) const
Returns the time zone abbreviation current at a specified time.
Definition: ktimezone.cpp:681
int toInt(bool *ok, int base) const
bool isEmpty() const
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const
QDateTime dateTime() const
Returns the date/time component of the instance, ignoring the time zone.
Definition: kdatetime.cpp:840
virtual int month(const QDate &date) const
Returns the month portion of a given date in the current calendar system.
Definition: kcalendarsystem.cpp:1344
Read/format time string without am/pm suffix but keep the 12/24h format as specified by locale time f...
Definition: klocale.h:1021
Time zone functions.
int secsTo(const KDateTime &other) const
Returns the number of seconds from this date/time to the other date/time.
Definition: kdatetime.cpp:1159
ushort unicode() const
Short name possessive format, e.g.
Definition: kcalendarsystem.h:58
QString right(int n) const
int hour() const
virtual bool isValid(int year, int month, int day) const =0
Returns whether a given date is valid in this calendar system.
Definition: kcalendarsystem.cpp:1133
QString toLower() const
int msec() const
A class representing a date and time with an associated time zone.
Definition: kdatetime.h:171
QString eraYear(const QDate &date, StringFormat format=ShortFormat) const
Definition: kcalendarsystem.cpp:1387
virtual int year(const QDate &date) const
Returns the year portion of a given date in the current calendar system.
Definition: kcalendarsystem.cpp:1331
bool dateMonthNamePossessive() const
Use this to determine whether in dates a possessive form of month name is preferred ("of January" rat...
Definition: klocale.cpp:222
int yearInEra(const QDate &date) const
Definition: kcalendarsystem.cpp:1400
QString mid(int position, int n) const
KLocale provides support for country specific stuff like the national language.
Definition: klocale.h:69
QString escape(const QString &plain)
int week(const QDate &date, int *yearNum=0) const
Returns the localized Week Number for the date.
Definition: kcalendarsystem.cpp:1703
QDate currentDate()
const QChar at(int position) const
int length() const
QString fromLatin1(const char *str, int size)
static KLocale::CalendarSystem calendarSystem(const QString &calendarType)
Definition: kcalendarsystem.cpp:183
virtual KDayPeriod dayPeriodForTime(const QTime &time) const
Definition: klocale_kde.cpp:2482
void getDate(const QDate date, int *year, int *month, int *day) const
Definition: kcalendarsystem.cpp:1307
virtual QString formatDate(const QDate &fromDate, const QString &toFormat, const KCalendarSystem *calendar=KGlobal::locale() ->calendar(), const KLocale *locale=KGlobal::locale(), KLocale::DigitSet digitSet=KGlobal::locale() ->dateTimeDigitSet(), KLocale::DateTimeFormatStandard standard=KLocale::KdeFormat) const
Definition: kdatetimeformatter.cpp:47
virtual bool setDate(QDate &date, int year, int month, int day) const
Changes the date's year, month and day.
Definition: kcalendarsystem.cpp:1222
SpecType timeType() const
Returns the time specification type of the date/time, i.e.
Definition: kdatetime.cpp:843
virtual int dayOfWeek(const QDate &date) const
Returns the weekday number for the given date.
Definition: kcalendarsystem.cpp:1686
virtual QString weekDayName(int weekDay, WeekDayNameFormat format=LongDayName) const =0
Gets specific calendar type week day name.
Definition: kcalendarsystem.cpp:1881
Exclude the seconds part of the time from display.
Definition: klocale.h:1020
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:22:11 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:22:11 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.