~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/corelib/tools/qdatetime_p.h

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
 **
 
3
 ** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
 
4
 **
 
5
 ** This file is part of the core module of the Qt Toolkit.
 
6
 **
 
7
 ** This file may be distributed under the terms of the Q Public License
 
8
** as defined by Trolltech AS of Norway and appearing in the file
 
9
** LICENSE.QPL included in the packaging of this file.
 
10
**
 
11
** This file may be distributed and/or modified under the terms of the
 
12
** GNU General Public License version 2 as published by the Free Software
 
13
** Foundation and appearing in the file LICENSE.GPL included in the
 
14
** packaging of this file.
 
15
**
 
16
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
 
17
**   information about Qt Commercial License Agreements.
 
18
** See http://www.trolltech.com/qpl/ for QPL licensing information.
 
19
** See http://www.trolltech.com/gpl/ for GPL licensing information.
 
20
**
 
21
** Contact info@trolltech.com if any conditions of this licensing are
 
22
** not clear to you.
 
23
 **
 
24
 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 
25
 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 
26
 **
 
27
 ****************************************************************************/
 
28
 
 
29
#ifndef QDATETIME_P_H
 
30
#define QDATETIME_P_H
 
31
 
 
32
#include "qplatformdefs.h"
 
33
 
 
34
#include "qatomic.h"
 
35
#include "qdatetime.h"
 
36
#include "qlist.h"
 
37
#include "qvariant.h"
 
38
 
 
39
class QDateTimePrivate
 
40
{
 
41
public:
 
42
    enum Spec { LocalUnknown = -1, LocalStandard = 0, LocalDST = 1, UTC = 2 };
 
43
 
 
44
    QDateTimePrivate() : ref(1), spec(LocalUnknown) {}
 
45
    QDateTimePrivate(const QDateTimePrivate &other)
 
46
        : ref(1), date(other.date), time(other.time), spec(other.spec)
 
47
    {}
 
48
 
 
49
    QAtomic ref;
 
50
    QDate date;
 
51
    QTime time;
 
52
    Spec spec;
 
53
 
 
54
    Spec getLocal(QDate &outDate, QTime &outTime) const;
 
55
    void getUTC(QDate &outDate, QTime &outTime) const;
 
56
};
 
57
 
 
58
 
 
59
class QFormatSection;
 
60
class QDateTimeParser
 
61
{
 
62
public:
 
63
    enum QDateTimeParserSkipMode {
 
64
        SkipNone,
 
65
        SkipForward,
 
66
        SkipBackward
 
67
    };
 
68
    enum Section {
 
69
        NoSection = 0x0000000,
 
70
 
 
71
        Day1 = 0x0000001,
 
72
        Day2 = 0x0000002,
 
73
        Day3 = 0x0000004,
 
74
        Day4 = 0x0000008,
 
75
        DayMask = (Day1|Day2|Day3|Day4),
 
76
 
 
77
        Month1 = 0x0000010,
 
78
        Month2 = 0x0000020,
 
79
        Month3 = 0x0000040,
 
80
        Month4 = 0x0000080,
 
81
        MonthMask = (Month1|Month2|Month3|Month4),
 
82
 
 
83
        Year2 = 0x0000100,
 
84
        Year4 = 0x0000200,
 
85
        YearMask = (Year2|Year4),
 
86
        DateMask = (DayMask|MonthMask|YearMask),
 
87
 
 
88
        Hour1 = 0x0000400,
 
89
        Hour2 = 0x0000800,
 
90
        HourMask = (Hour1|Hour2),
 
91
 
 
92
        Minute1 = 0x0001000,
 
93
        Minute2 = 0x0002000,
 
94
        MinuteMask = (Minute1|Minute2),
 
95
 
 
96
        Second1 = 0x0004000,
 
97
        Second2 = 0x0008000,
 
98
        SecondMask = (Second1|Second2),
 
99
 
 
100
        MSecond1 = 0x0010000,
 
101
        MSecond3 = 0x0020000,
 
102
        MSecondMask = (MSecond1|MSecond3),
 
103
 
 
104
        APLower = 0x0040000,
 
105
        APUpper = 0x0080000,
 
106
        APMask = (APLower|APUpper),
 
107
 
 
108
        TimeMask = (HourMask|MinuteMask|SecondMask|MSecondMask),
 
109
 
 
110
        Quote = 0x0100000,
 
111
        Separator = 0x0200000,
 
112
        FirstSection = 0x0400000,
 
113
        LastSection = 0x0800000
 
114
    };
 
115
 
 
116
    QDateTimeParser(const QString &f = QString(), QVariant::Type t = QVariant::DateTime);
 
117
    bool isSpecial(const QChar &c) const;
 
118
    QFormatSection findNextFormat(const QString &str, const int start);
 
119
    void parseFormat(const QString &format, QVariant::Type t);
 
120
    bool fromString(const QString &string, QDate *dateIn, QTime *timeIn);
 
121
 
 
122
    static bool withinBounds(QDateTimeParser::Section t, int num);
 
123
    static int getNumber(int index, const QString &str, int mindigits, int maxdigits, bool *ok, int *digits);
 
124
 
 
125
    static QFormatSection firstSection;
 
126
    static QFormatSection lastSection;
 
127
 
 
128
    QVariant::Type formatType;
 
129
    QList<QFormatSection> sect;
 
130
    QString format;
 
131
    uint display;
 
132
};
 
133
 
 
134
class QFormatSection
 
135
{
 
136
public:
 
137
    QFormatSection(int ind, const QString &sep);
 
138
    QFormatSection(int ind = -1, QDateTimeParser::Section typ = QDateTimeParser::NoSection);
 
139
    int length() const;
 
140
    static int length(QDateTimeParser::Section t);
 
141
    bool variableLength() const;
 
142
 
 
143
    int index;
 
144
    QString chars;
 
145
    QDateTimeParser::Section type;
 
146
};
 
147
 
 
148
#endif // QDATETIME_P_H