Qt 4.8
qgday.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtXmlPatterns module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "qbuiltintypes_p.h"
43 
44 #include "qgday_p.h"
45 
47 
48 using namespace QPatternist;
49 
50 GDay::GDay(const QDateTime &dateTime) : AbstractDateTime(dateTime)
51 {
52 }
53 
55 {
56  static const CaptureTable captureTable( // STATIC DATA
57  /* The extra paranthesis is a build fix for GCC 3.3. */
59  "^\\s*" /* Any preceding whitespace. */
60  "---" /* Delimiter. */
61  "(\\d{2})" /* The day part, "03". */
62  "(?:(?:(\\+|-))(\\d{2}):(\\d{2})|(Z))?" /* Timezone, "+08:24". */
63  "\\s*$" /* Any whitespace at the end. */))),
64  /*zoneOffsetSignP*/ 2,
65  /*zoneOffsetHourP*/ 3,
66  /*zoneOffsetMinuteP*/ 4,
67  /*zoneOffsetUTCSymbolP*/ 5,
68  /*yearP*/ -1,
69  /*monthP*/ -1,
70  /*dayP*/ 1);
71 
72  AtomicValue::Ptr err;
73  const QDateTime retval(create(err, lexical, captureTable));
74 
75  return err ? err : GDay::Ptr(new GDay(retval));
76 }
77 
79 {
80  QDateTime result(QDate(DefaultYear, DefaultMonth, dt.date().day()));
81  copyTimeSpec(dt, result);
82 
83  return GDay::Ptr(new GDay(result));
84 }
85 
87 {
89 }
90 
92 {
93  return BuiltinTypes::xsGDay;
94 }
95 
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
Base class for classes implementing values related to time, date or both.
The QRegExp class provides pattern matching using regular expressions.
Definition: qregexp.h:61
virtual QString stringValue() const
Definition: qgday.cpp:86
int day() const
Returns the day of the month (1 to 31) of this date.
Definition: qdatetime.cpp:395
The QDate class provides date functions.
Definition: qdatetime.h:55
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
GDay(const QDateTime &dateTime)
Definition: qgday.cpp:50
The QString class provides a Unicode character string.
Definition: qstring.h:83
virtual ItemType::Ptr type() const
Definition: qgday.cpp:91
QString toString(Qt::DateFormat f=Qt::TextDate) const
Returns the datetime as a string in the format given.
Definition: qdatetime.cpp:2628
static QDateTime create(AtomicValue::Ptr &errorMessage, const QString &lexicalSource, const CaptureTable &captTable)
AtomicValue::Ptr Ptr
Definition: qgday_p.h:72
static const AtomicType::Ptr xsGDay
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
static GDay::Ptr fromLexical(const QString &string)
Definition: qgday.cpp:54
Acts as a mapping table for AbstractDateTime::create() and describes where certain fields in a QRegEx...
The namespace for the internal API of QtXmlPatterns.
static GDay::Ptr fromDateTime(const QDateTime &dt)
Definition: qgday.cpp:78
static void copyTimeSpec(const QDateTime &from, QDateTime &to)
Makes the QDateTime::timeSpec() and QDateTime::zoneOffset() of ot * consistent to from...
QDate date() const
Returns the date part of the datetime.
Definition: qdatetime.cpp:2357
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216