42 #include <QStringList> 60 #define badData(msg) errorMessage = ValidationError::createError(msg); return QDateTime() 61 #define getCapt(sym) ((captTable.sym == -1) ? QString() : capts.at(captTable.sym)) 62 #define getSafeCapt(sym) ((captTable.sym == -1) ? QString() : capts.value(captTable.sym)) 78 if(yearStr.size() > 4 && yearStr.at(0) ==
QLatin1Char(
'0'))
80 badData(QtXmlPatterns::tr(
"Year %1 is invalid because it begins with %2.")
97 if(day > 31 || day < 1)
99 badData(QtXmlPatterns::tr(
"Day %1 is outside the range %2..%3.")
104 else if(month > 12 || month < -12 || month == 0)
106 badData(QtXmlPatterns::tr(
"Month %1 is outside the range %2..%3.")
117 "Overflow: Can't represent date %1.")
119 .arg(year).arg(month).arg(day)),
125 badData(QtXmlPatterns::tr(
"Day %1 is invalid for month %2.")
135 if(zoResult ==
Error)
142 QDate date(year, month, day);
145 if(captTable.
hour == -1)
172 if(mins != 0 || secs != 0 || msecs != 0)
174 badData(QtXmlPatterns::tr(
"Time 24:%1:%2.%3 is invalid. " 175 "Hour is 24, but minutes, seconds, " 176 "and milliseconds are not all 0; ")
177 .arg(mins).arg(secs).arg(msecs));
187 badData(QtXmlPatterns::tr(
"Time %1:%2:%3.%4 is invalid.")
188 .arg(hour).arg(mins).arg(secs).arg(msecs));
191 const QTime time(hour, mins, secs, msecs);
206 if(zoneOffsetSignStr.
isEmpty())
225 if(zoHour > 14 || zoHour < -14)
239 if(zoHour == 14 && zoMins != 0)
248 else if(zoMins > 59 || zoMins < -59)
258 if(zoHour == 0 && zoMins == 0)
265 ZOTotal zoneOffset = (zoHour * 60 + zoMins) * 60;
268 zoneOffset = -zoneOffset;
302 message = QtXmlPatterns::tr(
"Overflow: Date can't be represented.");
355 const int posZoneOffset =
qAbs(zoneOffset);
358 const int hours = posZoneOffset/(60 * 60);
359 const int minutes = (posZoneOffset % (60 * 60)) / 60;
397 "Calling AbstractDateTime::fromDateTime() makes no sense.");
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
#define QT_END_NAMESPACE
This macro expands to.
The QRegExp class provides pattern matching using regular expressions.
bool isValid() const
Returns true if this date is valid; otherwise returns false.
int toInt(bool *ok=0, int base=10) const
Returns the string converted to an int using base base, which is 10 by default and must be between 2 ...
QString timeToString() const
QString leftJustified(int width, QChar fill=QLatin1Char(' '), bool trunc=false) const Q_REQUIRED_RESULT
Returns a string of size width that contains this string padded by the fill character.
Due to strong interdependencies, this file contains the definitions for the classes Item...
QString dateToString() const
static AtomicValue::Ptr createError(const QString &description=QString(), const ReportContext::ErrorCode=ReportContext::FORG0001)
bool isValid() const
Returns true if both the date and the time are valid; otherwise returns false.
const QDateTime m_dateTime
The QDate class provides date functions.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
int msec() const
Returns the millisecond part (0 to 999) of the time.
The QString class provides a Unicode character string.
Q_DECL_CONSTEXPR T qAbs(const T &t)
static void setUtcOffset(QDateTime &result, const ZoneOffsetParseResult zoResult, const int zoOffset)
QString toString(Qt::DateFormat f=Qt::TextDate) const
Returns the datetime as a string in the format given.
static QDateTime create(AtomicValue::Ptr &errorMessage, const QString &lexicalSource, const CaptureTable &captTable)
void reserve(int size)
Attempts to allocate memory for at least size characters.
The QTime class provides clock time functions.
#define QT_BEGIN_NAMESPACE
This macro expands to.
AbstractDateTime(const QDateTime &dateTime)
QStringList capturedTexts() const
Returns a list of the captured text strings.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
The QStringList class provides a list of strings.
Acts as a mapping table for AbstractDateTime::create() and describes where certain fields in a QRegEx...
The namespace for the internal API of QtXmlPatterns.
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
static QChar fromLatin1(char c)
Converts the Latin-1 character c to its equivalent QChar.
void setTimeSpec(Qt::TimeSpec spec)
Sets the time specification used in this datetime to spec.
QDate addDays(int days) const
Returns a QDate object containing a date ndays later than the date of this object (or earlier if nday...
static QString formatData(const QString &data)
static ZOTotal parseZoneOffset(ZoneOffsetParseResult &result, const QStringList &capts, const CaptureTable &captTable)
Parses the zone offset. All types use zone offsets.
static void copyTimeSpec(const QDateTime &from, QDateTime &to)
Makes the QDateTime::timeSpec() and QDateTime::zoneOffset() of ot * consistent to from...
#define Q_ASSERT_X(cond, where, what)
QString & append(QChar c)
Contains functions used for formatting arguments, such as keywords and paths, in translated strings...
The QDateTime class provides date and time functions.
Represents an item in the XPath 2.0 Data Model.
static bool isRangeValid(const QDate &date, QString &message)
Qt::TimeSpec timeSpec() const
Returns the time specification of the datetime.
QString zoneOffsetToString() const
bool exactMatch(const QString &str) const
Returns true if str is matched exactly by this regular expression; otherwise returns false...
virtual Item fromValue(const QDateTime &dt) const
QTime time() const
Returns the time part of the datetime.
static QString serializeMSeconds(const MSecondProperty msecs)
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
bool isValid() const
Returns true if the time is valid; otherwise returns false.
void setUtcOffset(int seconds)