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 are 6 * met: 7 * 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above 11 * copyright notice, this list of conditions and the following disclaimer 12 * in the documentation and/or other materials provided with the 13 * distribution. 14 * * Neither the name of Google Inc. nor the names of its 15 * contributors may be used to endorse or promote products derived from 16 * this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31#ifndef LocaleMac_h 32#define LocaleMac_h 33 34#include "PlatformLocale.h" 35#include <wtf/Forward.h> 36#include <wtf/RetainPtr.h> 37#include <wtf/Vector.h> 38#include <wtf/text/WTFString.h> 39 40OBJC_CLASS NSCalendar; 41OBJC_CLASS NSDateFormatter; 42OBJC_CLASS NSLocale; 43 44namespace WebCore { 45 46class DateComponents; 47 48class LocaleMac : public Locale { 49public: 50 static PassOwnPtr<LocaleMac> create(NSLocale*); 51 ~LocaleMac(); 52 53#if PLATFORM(IOS) 54 virtual String formatDateTime(const DateComponents&, FormatType = FormatTypeUnspecified) override; 55#endif 56 57#if ENABLE(DATE_AND_TIME_INPUT_TYPES) 58 virtual String dateFormat() override; 59 virtual String monthFormat() override; 60 virtual String shortMonthFormat() override; 61 virtual String timeFormat() override; 62 virtual String shortTimeFormat() override; 63 virtual String dateTimeFormatWithSeconds() override; 64 virtual String dateTimeFormatWithoutSeconds() override; 65 virtual const Vector<String>& monthLabels() override; 66 virtual const Vector<String>& shortMonthLabels() override; 67 virtual const Vector<String>& standAloneMonthLabels() override; 68 virtual const Vector<String>& shortStandAloneMonthLabels() override; 69 virtual const Vector<String>& timeAMPMLabels() override; 70#endif 71 72private: 73 explicit LocaleMac(NSLocale*); 74 RetainPtr<NSDateFormatter> shortDateFormatter(); 75 virtual void initializeLocaleData() override; 76 77 RetainPtr<NSLocale> m_locale; 78 RetainPtr<NSCalendar> m_gregorianCalendar; 79#if ENABLE(DATE_AND_TIME_INPUT_TYPES) 80 Vector<String> m_monthLabels; 81 RetainPtr<NSDateFormatter> timeFormatter(); 82 RetainPtr<NSDateFormatter> shortTimeFormatter(); 83 RetainPtr<NSDateFormatter> dateTimeFormatterWithSeconds(); 84 RetainPtr<NSDateFormatter> dateTimeFormatterWithoutSeconds(); 85 86 String m_dateFormat; 87 String m_monthFormat; 88 String m_shortMonthFormat; 89 String m_timeFormatWithSeconds; 90 String m_timeFormatWithoutSeconds; 91 String m_dateTimeFormatWithSeconds; 92 String m_dateTimeFormatWithoutSeconds; 93 Vector<String> m_shortMonthLabels; 94 Vector<String> m_standAloneMonthLabels; 95 Vector<String> m_shortStandAloneMonthLabels; 96 Vector<String> m_timeAMPMLabels; 97#endif 98 bool m_didInitializeNumberData; 99}; 100 101} // namespace WebCore 102#endif 103