2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
8 // http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @file FLclDateTimeFormatter.cpp
19 * @brief This is the implementation file for DateTimeFormatter class.
23 #include <FBaseSysLog.h>
24 #include <FLclDateTimeFormatter.h>
25 #include <FLclNumberFormatter.h>
26 #include "FLcl_DateTimeFormatterImpl.h"
28 using namespace Tizen::Base;
29 using namespace Tizen::Base::Collection;
30 using namespace Tizen::Base::Utility;
32 namespace Tizen { namespace Locales
34 /////////////////////////////////////////////////////////////////////////////////////////////////////
37 DateTimeFormatter::DateTimeFormatter(void)
38 : __pNumberFormat(null)
40 , __pDateTimeFormatterImpl(null)
44 DateTimeFormatter::~DateTimeFormatter(void)
46 delete __pDateTimeFormatterImpl;
50 DateTimeFormatter::CreateDateFormatterN(DateTimeStyle style)
52 if (style == DATE_TIME_STYLE_NONE)
54 style = DATE_TIME_STYLE_DEFAULT;
57 return _DateTimeFormatterImpl::CreateInstanceN(style, DATE_TIME_STYLE_NONE);
62 DateTimeFormatter::CreateDateFormatterN(const Locale& locale, DateTimeStyle style)
64 if (style == DATE_TIME_STYLE_NONE)
66 style = DATE_TIME_STYLE_DEFAULT;
69 return _DateTimeFormatterImpl::CreateInstanceN(locale, style, DATE_TIME_STYLE_NONE);
74 DateTimeFormatter::CreateTimeFormatterN(DateTimeStyle style)
76 if (style == DATE_TIME_STYLE_NONE)
78 style = DATE_TIME_STYLE_DEFAULT;
81 return _DateTimeFormatterImpl::CreateInstanceN(DATE_TIME_STYLE_NONE, style);
86 DateTimeFormatter::CreateTimeFormatterN(const Locale& locale, DateTimeStyle style)
88 if (style == DATE_TIME_STYLE_NONE)
90 style = DATE_TIME_STYLE_DEFAULT;
93 return _DateTimeFormatterImpl::CreateInstanceN(locale, DATE_TIME_STYLE_NONE, style);
98 DateTimeFormatter::CreateDateTimeFormatterN(DateTimeStyle dateStyle, DateTimeStyle timeStyle)
100 if (dateStyle == DATE_TIME_STYLE_NONE)
102 dateStyle = DATE_TIME_STYLE_DEFAULT;
105 if (timeStyle == DATE_TIME_STYLE_NONE)
107 timeStyle = DATE_TIME_STYLE_DEFAULT;
110 return _DateTimeFormatterImpl::CreateInstanceN(dateStyle, timeStyle);
115 DateTimeFormatter::CreateDateTimeFormatterN(const Locale& locale, DateTimeStyle dateStyle, DateTimeStyle timeStyle)
117 if (dateStyle == DATE_TIME_STYLE_NONE)
119 dateStyle = DATE_TIME_STYLE_DEFAULT;
122 if (timeStyle == DATE_TIME_STYLE_NONE)
124 timeStyle = DATE_TIME_STYLE_DEFAULT;
127 return _DateTimeFormatterImpl::CreateInstanceN(locale, dateStyle, timeStyle);
132 DateTimeFormatter::Format(const DateTime& date, String& strBuf) const
134 SysAssertf(__pDateTimeFormatterImpl != null, "Not yet constructed! Construct() should be called before use.");
135 return __pDateTimeFormatterImpl->Format(date, strBuf);
139 DateTimeFormatter::Format(const Calendar& calendar, String& strBuf) const
141 SysAssertf(__pDateTimeFormatterImpl != null, "Not yet constructed! Construct() should be called before use.");
142 return __pDateTimeFormatterImpl->Format(calendar, strBuf);
146 DateTimeFormatter::ApplyPattern(const String& pattern)
148 SysAssertf(__pDateTimeFormatterImpl != null, "Not yet constructed! Construct() should be called before use.");
149 SysTryReturnResult(NID_LCL, !pattern.IsEmpty(), E_INVALID_ARG, "Invalid argument is used. Input pattern is empty");
151 return __pDateTimeFormatterImpl->ApplyPattern(pattern);
156 DateTimeFormatter::GetPattern(void) const
158 SysAssertf(__pDateTimeFormatterImpl != null, "Not yet constructed! Construct() should be called before use.");
159 return __pDateTimeFormatterImpl->GetPattern();
163 const DateTimeSymbols*
164 DateTimeFormatter::GetDateTimeSymbols(void) const
166 SysAssertf(__pDateTimeFormatterImpl != null, "Not yet constructed! Construct() should be called before use.");
167 return __pDateTimeFormatterImpl->GetDateTimeSymbols();
172 DateTimeFormatter::SetDateTimeSymbols(const DateTimeSymbols& newSymbols)
174 SysAssertf(__pDateTimeFormatterImpl != null, "Not yet constructed! Construct() should be called before use.");
175 __pDateTimeFormatterImpl->SetDateTimeSymbols(newSymbols);