2
* Copyright (C) 2012 Google Inc. All rights reserved.
4
* Redistribution and use in source and binary forms, with or without
5
* modification, are permitted provided that the following conditions
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.
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
27
#include "PlatformLocale.h"
28
#include <wtf/DateMath.h>
29
#include <wtf/PassOwnPtr.h>
33
class LocaleNone : public Locale {
35
virtual ~LocaleNone();
38
virtual void initializeLocaleData() OVERRIDE FINAL;
39
#if ENABLE(CALENDAR_PICKER)
40
virtual bool isRTL() OVERRIDE;
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;
55
Vector<String> m_timeAMPMLabels;
56
Vector<String> m_shortMonthLabels;
57
Vector<String> m_monthLabels;
61
PassOwnPtr<Locale> Locale::create(const AtomicString&)
63
return adoptPtr(new LocaleNone());
66
LocaleNone::~LocaleNone()
70
void LocaleNone::initializeLocaleData()
74
#if ENABLE(CALENDAR_PICKER)
75
bool LocaleNone::isRTL()
81
#if ENABLE(DATE_AND_TIME_INPUT_TYPES)
82
const Vector<String>& LocaleNone::monthLabels()
84
if (!m_monthLabels.isEmpty())
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]);
92
String LocaleNone::dateFormat()
94
return ASCIILiteral("dd/MM/yyyyy");
97
String LocaleNone::monthFormat()
99
return ASCIILiteral("yyyy-MM");
102
String LocaleNone::timeFormat()
104
return ASCIILiteral("HH:mm:ss");
107
String LocaleNone::shortTimeFormat()
109
return ASCIILiteral("HH:mm");
112
String LocaleNone::dateTimeFormatWithSeconds()
114
return ASCIILiteral("dd/MM/yyyyy HH:mm:ss");
117
String LocaleNone::dateTimeFormatWithoutSeconds()
119
return ASCIILiteral("dd/MM/yyyyy HH:mm");
122
const Vector<String>& LocaleNone::shortMonthLabels()
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;
132
const Vector<String>& LocaleNone::shortStandAloneMonthLabels()
134
return shortMonthLabels();
137
const Vector<String>& LocaleNone::standAloneMonthLabels()
139
return monthLabels();
142
const Vector<String>& LocaleNone::timeAMPMLabels()
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;
154
} // namespace WebCore