blob: 9dc5c00a5a1bbe30acfaeb28e78d6c2906e7c3a1 [file] [log] [blame]
tkent@chromium.orgfff5a972012-09-14 11:49:23 +00001/*
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"
tkent@chromium.orgfe8acbf2012-10-29 07:02:39 +000027#include "PlatformLocale.h"
tkent@chromium.orgeae929b2012-10-19 05:08:47 +000028#include <wtf/DateMath.h>
tkent@chromium.orgfff5a972012-09-14 11:49:23 +000029#include <wtf/PassOwnPtr.h>
30
31namespace WebCore {
32
tkent@chromium.org0c53f9c2012-10-29 08:51:17 +000033class LocaleNone : public Locale {
tkent@chromium.orgfff5a972012-09-14 11:49:23 +000034public:
35 virtual ~LocaleNone();
36
37private:
tkent@chromium.org0c53f9c2012-10-29 08:51:17 +000038 virtual void initializeLocaleData() OVERRIDE FINAL;
tkent@chromium.org3001fd12012-09-28 16:46:05 +000039#if ENABLE(CALENDAR_PICKER)
tkent@chromium.orgc84ce282012-10-11 07:45:26 +000040 virtual bool isRTL() OVERRIDE;
tkent@chromium.org3001fd12012-09-28 16:46:05 +000041#endif
tkent@chromium.org28c02372012-11-02 11:27:50 +000042#if ENABLE(DATE_AND_TIME_INPUT_TYPES)
yosin@chromium.org89c0c132012-10-02 06:48:59 +000043 virtual String dateFormat() OVERRIDE;
tkent@chromium.org5cb0c802012-10-18 14:32:08 +000044 virtual String monthFormat() OVERRIDE;
tkent@chromium.org5a23f9b2012-10-26 14:22:53 +000045 virtual String timeFormat() OVERRIDE;
46 virtual String shortTimeFormat() OVERRIDE;
tkent@chromium.org28c02372012-11-02 11:27:50 +000047 virtual const Vector<String>& monthLabels() OVERRIDE;
tkent@chromium.orgeae929b2012-10-19 05:08:47 +000048 virtual const Vector<String>& shortMonthLabels() OVERRIDE;
tkent@chromium.orga9f86e42012-10-23 01:22:48 +000049 virtual const Vector<String>& standAloneMonthLabels() OVERRIDE;
tkent@chromium.orgeae929b2012-10-19 05:08:47 +000050 virtual const Vector<String>& shortStandAloneMonthLabels() OVERRIDE;
tkent@chromium.org5a23f9b2012-10-26 14:22:53 +000051 virtual const Vector<String>& timeAMPMLabels() OVERRIDE;
tkent@chromium.orgeae929b2012-10-19 05:08:47 +000052
tkent@chromium.org5a23f9b2012-10-26 14:22:53 +000053 Vector<String> m_timeAMPMLabels;
tkent@chromium.orgeae929b2012-10-19 05:08:47 +000054 Vector<String> m_shortMonthLabels;
tkent@chromium.orga9f86e42012-10-23 01:22:48 +000055 Vector<String> m_monthLabels;
56#endif
tkent@chromium.orgfff5a972012-09-14 11:49:23 +000057};
58
tkent@chromium.org0c53f9c2012-10-29 08:51:17 +000059PassOwnPtr<Locale> Locale::create(const AtomicString&)
tkent@chromium.orgfff5a972012-09-14 11:49:23 +000060{
61 return adoptPtr(new LocaleNone());
62}
63
64LocaleNone::~LocaleNone()
65{
66}
67
tkent@chromium.org0c53f9c2012-10-29 08:51:17 +000068void LocaleNone::initializeLocaleData()
tkent@chromium.orgfff5a972012-09-14 11:49:23 +000069{
70}
71
tkent@chromium.org3001fd12012-09-28 16:46:05 +000072#if ENABLE(CALENDAR_PICKER)
tkent@chromium.orgc84ce282012-10-11 07:45:26 +000073bool LocaleNone::isRTL()
74{
75 return false;
76}
tkent@chromium.org3001fd12012-09-28 16:46:05 +000077#endif
78
tkent@chromium.org28c02372012-11-02 11:27:50 +000079#if ENABLE(DATE_AND_TIME_INPUT_TYPES)
tkent@chromium.orga9f86e42012-10-23 01:22:48 +000080const Vector<String>& LocaleNone::monthLabels()
81{
82 if (!m_monthLabels.isEmpty())
83 return m_monthLabels;
84 m_monthLabels.reserveCapacity(WTF_ARRAY_LENGTH(WTF::monthFullName));
85 for (unsigned i = 0; i < WTF_ARRAY_LENGTH(WTF::monthFullName); ++i)
86 m_monthLabels.append(WTF::monthFullName[i]);
87 return m_monthLabels;
88}
tkent@chromium.orga9f86e42012-10-23 01:22:48 +000089
yosin@chromium.org89c0c132012-10-02 06:48:59 +000090String LocaleNone::dateFormat()
91{
yosin@chromium.org4fc8d012012-10-02 08:03:59 +000092 return ASCIILiteral("dd/MM/yyyyy");
yosin@chromium.org89c0c132012-10-02 06:48:59 +000093}
tkent@chromium.org5cb0c802012-10-18 14:32:08 +000094
95String LocaleNone::monthFormat()
96{
97 return ASCIILiteral("yyyy-MM");
98}
tkent@chromium.orgeae929b2012-10-19 05:08:47 +000099
tkent@chromium.org5a23f9b2012-10-26 14:22:53 +0000100String LocaleNone::timeFormat()
101{
102 return ASCIILiteral("HH:mm:ss");
103}
104
105String LocaleNone::shortTimeFormat()
106{
107 return ASCIILiteral("HH:mm");
108}
109
tkent@chromium.orgeae929b2012-10-19 05:08:47 +0000110const Vector<String>& LocaleNone::shortMonthLabels()
111{
112 if (!m_shortMonthLabels.isEmpty())
113 return m_shortMonthLabels;
114 m_shortMonthLabels.reserveCapacity(WTF_ARRAY_LENGTH(WTF::monthName));
115 for (unsigned i = 0; i < WTF_ARRAY_LENGTH(WTF::monthName); ++i)
116 m_shortMonthLabels.append(WTF::monthName[i]);
117 return m_shortMonthLabels;
118}
119
120const Vector<String>& LocaleNone::shortStandAloneMonthLabels()
121{
122 return shortMonthLabels();
123}
tkent@chromium.orga9f86e42012-10-23 01:22:48 +0000124
125const Vector<String>& LocaleNone::standAloneMonthLabels()
126{
127 return monthLabels();
128}
tkent@chromium.org5a23f9b2012-10-26 14:22:53 +0000129
130const Vector<String>& LocaleNone::timeAMPMLabels()
131{
132 if (!m_timeAMPMLabels.isEmpty())
133 return m_timeAMPMLabels;
134 m_timeAMPMLabels.reserveCapacity(2);
135 m_timeAMPMLabels.append("AM");
136 m_timeAMPMLabels.append("PM");
137 return m_timeAMPMLabels;
138}
139
yosin@chromium.org89c0c132012-10-02 06:48:59 +0000140#endif
141
tkent@chromium.orgfff5a972012-09-14 11:49:23 +0000142} // namespace WebCore