tkent@chromium.org | fff5a97 | 2012-09-14 11:49:23 +0000 | [diff] [blame] | 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" |
tkent@chromium.org | fe8acbf | 2012-10-29 07:02:39 +0000 | [diff] [blame] | 27 | #include "PlatformLocale.h" |
tkent@chromium.org | eae929b | 2012-10-19 05:08:47 +0000 | [diff] [blame] | 28 | #include <wtf/DateMath.h> |
tkent@chromium.org | fff5a97 | 2012-09-14 11:49:23 +0000 | [diff] [blame] | 29 | #include <wtf/PassOwnPtr.h> |
| 30 | |
| 31 | namespace WebCore { |
| 32 | |
tkent@chromium.org | 0c53f9c | 2012-10-29 08:51:17 +0000 | [diff] [blame] | 33 | class LocaleNone : public Locale { |
tkent@chromium.org | fff5a97 | 2012-09-14 11:49:23 +0000 | [diff] [blame] | 34 | public: |
| 35 | virtual ~LocaleNone(); |
| 36 | |
| 37 | private: |
tkent@chromium.org | 0c53f9c | 2012-10-29 08:51:17 +0000 | [diff] [blame] | 38 | virtual void initializeLocaleData() OVERRIDE FINAL; |
tkent@chromium.org | 3001fd1 | 2012-09-28 16:46:05 +0000 | [diff] [blame] | 39 | #if ENABLE(CALENDAR_PICKER) |
tkent@chromium.org | c84ce28 | 2012-10-11 07:45:26 +0000 | [diff] [blame] | 40 | virtual bool isRTL() OVERRIDE; |
tkent@chromium.org | 3001fd1 | 2012-09-28 16:46:05 +0000 | [diff] [blame] | 41 | #endif |
tkent@chromium.org | 28c0237 | 2012-11-02 11:27:50 +0000 | [diff] [blame] | 42 | #if ENABLE(DATE_AND_TIME_INPUT_TYPES) |
yosin@chromium.org | 89c0c13 | 2012-10-02 06:48:59 +0000 | [diff] [blame] | 43 | virtual String dateFormat() OVERRIDE; |
tkent@chromium.org | 5cb0c80 | 2012-10-18 14:32:08 +0000 | [diff] [blame] | 44 | virtual String monthFormat() OVERRIDE; |
tkent@chromium.org | 5a23f9b | 2012-10-26 14:22:53 +0000 | [diff] [blame] | 45 | virtual String timeFormat() OVERRIDE; |
| 46 | virtual String shortTimeFormat() OVERRIDE; |
tkent@chromium.org | 28c0237 | 2012-11-02 11:27:50 +0000 | [diff] [blame] | 47 | virtual const Vector<String>& monthLabels() OVERRIDE; |
tkent@chromium.org | eae929b | 2012-10-19 05:08:47 +0000 | [diff] [blame] | 48 | virtual const Vector<String>& shortMonthLabels() OVERRIDE; |
tkent@chromium.org | a9f86e4 | 2012-10-23 01:22:48 +0000 | [diff] [blame] | 49 | virtual const Vector<String>& standAloneMonthLabels() OVERRIDE; |
tkent@chromium.org | eae929b | 2012-10-19 05:08:47 +0000 | [diff] [blame] | 50 | virtual const Vector<String>& shortStandAloneMonthLabels() OVERRIDE; |
tkent@chromium.org | 5a23f9b | 2012-10-26 14:22:53 +0000 | [diff] [blame] | 51 | virtual const Vector<String>& timeAMPMLabels() OVERRIDE; |
tkent@chromium.org | eae929b | 2012-10-19 05:08:47 +0000 | [diff] [blame] | 52 | |
tkent@chromium.org | 5a23f9b | 2012-10-26 14:22:53 +0000 | [diff] [blame] | 53 | Vector<String> m_timeAMPMLabels; |
tkent@chromium.org | eae929b | 2012-10-19 05:08:47 +0000 | [diff] [blame] | 54 | Vector<String> m_shortMonthLabels; |
tkent@chromium.org | a9f86e4 | 2012-10-23 01:22:48 +0000 | [diff] [blame] | 55 | Vector<String> m_monthLabels; |
| 56 | #endif |
tkent@chromium.org | fff5a97 | 2012-09-14 11:49:23 +0000 | [diff] [blame] | 57 | }; |
| 58 | |
tkent@chromium.org | 0c53f9c | 2012-10-29 08:51:17 +0000 | [diff] [blame] | 59 | PassOwnPtr<Locale> Locale::create(const AtomicString&) |
tkent@chromium.org | fff5a97 | 2012-09-14 11:49:23 +0000 | [diff] [blame] | 60 | { |
| 61 | return adoptPtr(new LocaleNone()); |
| 62 | } |
| 63 | |
| 64 | LocaleNone::~LocaleNone() |
| 65 | { |
| 66 | } |
| 67 | |
tkent@chromium.org | 0c53f9c | 2012-10-29 08:51:17 +0000 | [diff] [blame] | 68 | void LocaleNone::initializeLocaleData() |
tkent@chromium.org | fff5a97 | 2012-09-14 11:49:23 +0000 | [diff] [blame] | 69 | { |
| 70 | } |
| 71 | |
tkent@chromium.org | 3001fd1 | 2012-09-28 16:46:05 +0000 | [diff] [blame] | 72 | #if ENABLE(CALENDAR_PICKER) |
tkent@chromium.org | c84ce28 | 2012-10-11 07:45:26 +0000 | [diff] [blame] | 73 | bool LocaleNone::isRTL() |
| 74 | { |
| 75 | return false; |
| 76 | } |
tkent@chromium.org | 3001fd1 | 2012-09-28 16:46:05 +0000 | [diff] [blame] | 77 | #endif |
| 78 | |
tkent@chromium.org | 28c0237 | 2012-11-02 11:27:50 +0000 | [diff] [blame] | 79 | #if ENABLE(DATE_AND_TIME_INPUT_TYPES) |
tkent@chromium.org | a9f86e4 | 2012-10-23 01:22:48 +0000 | [diff] [blame] | 80 | const 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.org | a9f86e4 | 2012-10-23 01:22:48 +0000 | [diff] [blame] | 89 | |
yosin@chromium.org | 89c0c13 | 2012-10-02 06:48:59 +0000 | [diff] [blame] | 90 | String LocaleNone::dateFormat() |
| 91 | { |
yosin@chromium.org | 4fc8d01 | 2012-10-02 08:03:59 +0000 | [diff] [blame] | 92 | return ASCIILiteral("dd/MM/yyyyy"); |
yosin@chromium.org | 89c0c13 | 2012-10-02 06:48:59 +0000 | [diff] [blame] | 93 | } |
tkent@chromium.org | 5cb0c80 | 2012-10-18 14:32:08 +0000 | [diff] [blame] | 94 | |
| 95 | String LocaleNone::monthFormat() |
| 96 | { |
| 97 | return ASCIILiteral("yyyy-MM"); |
| 98 | } |
tkent@chromium.org | eae929b | 2012-10-19 05:08:47 +0000 | [diff] [blame] | 99 | |
tkent@chromium.org | 5a23f9b | 2012-10-26 14:22:53 +0000 | [diff] [blame] | 100 | String LocaleNone::timeFormat() |
| 101 | { |
| 102 | return ASCIILiteral("HH:mm:ss"); |
| 103 | } |
| 104 | |
| 105 | String LocaleNone::shortTimeFormat() |
| 106 | { |
| 107 | return ASCIILiteral("HH:mm"); |
| 108 | } |
| 109 | |
tkent@chromium.org | eae929b | 2012-10-19 05:08:47 +0000 | [diff] [blame] | 110 | const 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 | |
| 120 | const Vector<String>& LocaleNone::shortStandAloneMonthLabels() |
| 121 | { |
| 122 | return shortMonthLabels(); |
| 123 | } |
tkent@chromium.org | a9f86e4 | 2012-10-23 01:22:48 +0000 | [diff] [blame] | 124 | |
| 125 | const Vector<String>& LocaleNone::standAloneMonthLabels() |
| 126 | { |
| 127 | return monthLabels(); |
| 128 | } |
tkent@chromium.org | 5a23f9b | 2012-10-26 14:22:53 +0000 | [diff] [blame] | 129 | |
| 130 | const 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.org | 89c0c13 | 2012-10-02 06:48:59 +0000 | [diff] [blame] | 140 | #endif |
| 141 | |
tkent@chromium.org | fff5a97 | 2012-09-14 11:49:23 +0000 | [diff] [blame] | 142 | } // namespace WebCore |