~ubuntu-branches/ubuntu/raring/qtwebkit-source/raring-proposed

« back to all changes in this revision

Viewing changes to Source/WebCore/platform/text/LocaleNone.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-02-18 14:24:18 UTC
  • Revision ID: package-import@ubuntu.com-20130218142418-eon0jmjg3nj438uy
Tags: upstream-2.3
ImportĀ upstreamĀ versionĀ 2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2012 Google Inc. All rights reserved.
 
3
 *
 
4
 * Redistribution and use in source and binary forms, with or without
 
5
 * modification, are permitted provided that the following conditions
 
6
 * are met:
 
7
 * 1.  Redistributions of source code must retain the above copyright
 
8
 *     notice, this list of conditions and the following disclaimer.
 
9
 * 2.  Redistributions in binary form must reproduce the above copyright
 
10
 *     notice, this list of conditions and the following disclaimer in the
 
11
 *     documentation and/or other materials provided with the distribution.
 
12
 *
 
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
 
14
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 
15
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 
16
 * ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE
 
17
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 
18
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 
19
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 
20
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 
21
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 
22
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 
23
 * SUCH DAMAGE.
 
24
 */
 
25
 
 
26
#include "config.h"
 
27
#include "PlatformLocale.h"
 
28
#include <wtf/DateMath.h>
 
29
#include <wtf/PassOwnPtr.h>
 
30
 
 
31
namespace WebCore {
 
32
 
 
33
class LocaleNone : public Locale {
 
34
public:
 
35
    virtual ~LocaleNone();
 
36
 
 
37
private:
 
38
    virtual void initializeLocaleData() OVERRIDE FINAL;
 
39
#if ENABLE(CALENDAR_PICKER)
 
40
    virtual bool isRTL() OVERRIDE;
 
41
#endif
 
42
#if ENABLE(DATE_AND_TIME_INPUT_TYPES)
 
43
    virtual String dateFormat() OVERRIDE;
 
44
    virtual String monthFormat() OVERRIDE;
 
45
    virtual String timeFormat() OVERRIDE;
 
46
    virtual String shortTimeFormat() OVERRIDE;
 
47
    virtual String dateTimeFormatWithSeconds() OVERRIDE;
 
48
    virtual String dateTimeFormatWithoutSeconds() OVERRIDE;
 
49
    virtual const Vector<String>& monthLabels() OVERRIDE;
 
50
    virtual const Vector<String>& shortMonthLabels() OVERRIDE;
 
51
    virtual const Vector<String>& standAloneMonthLabels() OVERRIDE;
 
52
    virtual const Vector<String>& shortStandAloneMonthLabels() OVERRIDE;
 
53
    virtual const Vector<String>& timeAMPMLabels() OVERRIDE;
 
54
 
 
55
    Vector<String> m_timeAMPMLabels;
 
56
    Vector<String> m_shortMonthLabels;
 
57
    Vector<String> m_monthLabels;
 
58
#endif
 
59
};
 
60
 
 
61
PassOwnPtr<Locale> Locale::create(const AtomicString&)
 
62
{
 
63
    return adoptPtr(new LocaleNone());
 
64
}
 
65
 
 
66
LocaleNone::~LocaleNone()
 
67
{
 
68
}
 
69
 
 
70
void LocaleNone::initializeLocaleData()
 
71
{
 
72
}
 
73
 
 
74
#if ENABLE(CALENDAR_PICKER)
 
75
bool LocaleNone::isRTL()
 
76
{
 
77
    return false;
 
78
}
 
79
#endif
 
80
 
 
81
#if ENABLE(DATE_AND_TIME_INPUT_TYPES)
 
82
const Vector<String>& LocaleNone::monthLabels()
 
83
{
 
84
    if (!m_monthLabels.isEmpty())
 
85
        return m_monthLabels;
 
86
    m_monthLabels.reserveCapacity(WTF_ARRAY_LENGTH(WTF::monthFullName));
 
87
    for (unsigned i = 0; i < WTF_ARRAY_LENGTH(WTF::monthFullName); ++i)
 
88
        m_monthLabels.append(WTF::monthFullName[i]);
 
89
    return m_monthLabels;
 
90
}
 
91
 
 
92
String LocaleNone::dateFormat()
 
93
{
 
94
    return ASCIILiteral("dd/MM/yyyyy");
 
95
}
 
96
 
 
97
String LocaleNone::monthFormat()
 
98
{
 
99
    return ASCIILiteral("yyyy-MM");
 
100
}
 
101
 
 
102
String LocaleNone::timeFormat()
 
103
{
 
104
    return ASCIILiteral("HH:mm:ss");
 
105
}
 
106
 
 
107
String LocaleNone::shortTimeFormat()
 
108
{
 
109
    return ASCIILiteral("HH:mm");
 
110
}
 
111
 
 
112
String LocaleNone::dateTimeFormatWithSeconds()
 
113
{
 
114
    return ASCIILiteral("dd/MM/yyyyy HH:mm:ss");
 
115
}
 
116
 
 
117
String LocaleNone::dateTimeFormatWithoutSeconds()
 
118
{
 
119
    return ASCIILiteral("dd/MM/yyyyy HH:mm");
 
120
}
 
121
 
 
122
const Vector<String>& LocaleNone::shortMonthLabels()
 
123
{
 
124
    if (!m_shortMonthLabels.isEmpty())
 
125
        return m_shortMonthLabels;
 
126
    m_shortMonthLabels.reserveCapacity(WTF_ARRAY_LENGTH(WTF::monthName));
 
127
    for (unsigned i = 0; i < WTF_ARRAY_LENGTH(WTF::monthName); ++i)
 
128
        m_shortMonthLabels.append(WTF::monthName[i]);
 
129
    return m_shortMonthLabels;
 
130
}
 
131
 
 
132
const Vector<String>& LocaleNone::shortStandAloneMonthLabels()
 
133
{
 
134
    return shortMonthLabels();
 
135
}
 
136
 
 
137
const Vector<String>& LocaleNone::standAloneMonthLabels()
 
138
{
 
139
    return monthLabels();
 
140
}
 
141
 
 
142
const Vector<String>& LocaleNone::timeAMPMLabels()
 
143
{
 
144
    if (!m_timeAMPMLabels.isEmpty())
 
145
        return m_timeAMPMLabels;
 
146
    m_timeAMPMLabels.reserveCapacity(2);
 
147
    m_timeAMPMLabels.append("AM");
 
148
    m_timeAMPMLabels.append("PM");
 
149
    return m_timeAMPMLabels;
 
150
}
 
151
 
 
152
#endif
 
153
 
 
154
} // namespace WebCore