Apply historical dst offset for timezone.
[platform/framework/native/appfw.git] / src / locales / FLcl_DateTimeFormatterImpl.h
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 /**
18  * @file        FLcl_DateTimeFormatterImpl.h
19  * @brief       This is the header file for the _DateTimeFormatterImpl class.
20  *
21  * This header file contains the declarations of the _DateTimeFormatterImpl class.
22  *
23  */
24 #ifndef _FLCL_INTERNAL_DATE_TIME_FORMATTER_IMPL_H_
25 #define _FLCL_INTERNAL_DATE_TIME_FORMATTER_IMPL_H_
26
27 // Includes
28 #include <FLclLocale.h>
29 #include <FLclCalendar.h>
30 #include <FLclDateTimeSymbols.h>
31 #include <FLclDateTimeFormatter.h>
32
33
34 namespace Tizen { namespace Locales
35 {
36 class NumberFormatter;
37 class _LocaleData;
38 };
39 };
40
41 namespace U_ICU_NAMESPACE
42 {
43         class SimpleDateFormat;
44 }
45
46 namespace Tizen { namespace Locales
47 {
48
49 class _DateTimeFormatterImpl
50         : public Tizen::Base::Object
51 {
52
53 public:
54         _DateTimeFormatterImpl(void);
55         ~_DateTimeFormatterImpl(void);
56
57
58         static DateTimeFormatter* CreateInstanceN(const Locale& locale, DateTimeStyle dateStyle, DateTimeStyle timeStyle);
59         static DateTimeFormatter* CreateInstanceN(DateTimeStyle dateStyle, DateTimeStyle timeStyle);
60
61
62 // Operations
63 public:
64         /**
65          * Formats a DateTime object into a date/time string and appends the resulting string to the specified string buffer.
66          *
67          * @since               1.0
68          * @return          An error code
69          * @param[in]       date                The DateTime object to format
70          * @param[out]      str                 The String to append the resulting string to
71          * @exception       E_SUCCESS           The method was successful.
72          * @remarks         This method does not handle the time zone information, so "z" pattern always returns "GMT+00:00".
73          * @see                 Tizen::Base::DateTime
74          */
75         virtual result Format(const Tizen::Base::DateTime& date, Tizen::Base::String& str) const;
76
77
78         /**
79          * Formats a Calendar object into a date/time string and appends the resulting string to the specified string buffer.
80          *
81          * @since               1.0
82          * @return          An error code
83          * @param[in]       calendar                The Calendar object to format
84          * @param[out]      str                     The String to append the resulting string to
85          * @exception       E_SUCCESS               The method was successful.
86          * @see                 Tizen::Base::DateTime
87          */
88         virtual result Format(const Calendar& calendar, Tizen::Base::String& str) const;
89
90
91 //private:
92
93 // Operation
94 public:
95         /**
96         * Applies the specified pattern string to the date format.
97         *
98         * @since                    1.0
99         * @param[in]            pattern                 The new date and time pattern for the date format
100         * @exception            E_SUCCESS               The method was successful.
101         * @exception            E_INVALID_ARG           The length of specified @c pattern is 0.
102         */
103         result ApplyPattern(const Tizen::Base::String& pattern);
104
105
106         /**
107         * Gets a pattern string describing the date format.
108         *
109         * @since            1.0
110         * @return           A String describing the date format
111         */
112         Tizen::Base::String GetPattern(void) const;
113
114
115         /**
116         * Gets the date and time format symbols of the formatter.
117         *
118         * @since                1.0
119         * @return               A pointer to DateTimeSymbols for the formatter instance
120         * @see                  SetDateTimeSymbols()
121         */
122         const DateTimeSymbols* GetDateTimeSymbols(void);
123
124
125         /**
126         * Sets the date and time format symbols of the date format.
127         *
128         * @since                1.0
129         * @param[in]        newSymbols          The new date and time format symbols
130         * @see                  GetDateTimeSymbols()
131         */
132         void SetDateTimeSymbols(const DateTimeSymbols& newSymbols);
133
134         /**
135          * Formats a DateTime into a date/time string and appends the result string to a given string buffer.
136          *
137          * @return              An error code
138          * @param[in]           date                    The DateTime object to format
139          * @param[in]           pos                     On input: an alignment field, if desired @n
140          *                                              On output: the offsets of the alignment field
141          * @param[out]          str                     The String where the formatted string is to be appended
142          * @exception           E_SUCCESS               The method was successful.
143          * @see                 Tizen::Base::DateTime
144          */
145         result Format(const Tizen::Base::DateTime& date, _FieldPosition& pos, Tizen::Base::String& str) const;
146
147
148         /**
149          * Formats a Calendar into a date/time string and appends the result string to a given string buffer.
150          *
151          * @return              An error code
152          * @param[in]           cal                     The Calendar object to format
153          * @param[in]           pos                     On input: an alignment field, if desired @n
154          *                                              On output: the offsets of the alignment field
155          * @param[out]          str                     The String where the formatted string is to be appended
156          * @exception           E_SUCCESS               The method was successful.
157          * @see                 Calendar()
158          */
159         result Format(const Calendar& calendar, _FieldPosition& pos, Tizen::Base::String& str) const;
160
161         static bool ValidateDateTimeStyle(DateTimeStyle dateTimeStyle);
162 private:
163         _DateTimeFormatterImpl(const _DateTimeFormatterImpl& dateTimeFormatterImpl);
164         _DateTimeFormatterImpl& operator =(const _DateTimeFormatterImpl& dateTimeFormatterImpl);
165
166         U_ICU_NAMESPACE::SimpleDateFormat* GetIcuDateFormatterN(const Locale& locale, DateTimeStyle dateStyle, DateTimeStyle timeStyle);
167
168 private:
169         DateTimeSymbols* __pSymbols;
170         U_ICU_NAMESPACE::SimpleDateFormat* __pIcuDateFormatter;
171         Locale* __pLocale;
172 }; // _DateTimeFormatterImpl
173 };
174 };      // Tizen::Locales
175
176 #endif //_FLCL_INTERNAL_DATE_TIME_FORMATTER_IMPL_H_
177