2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FLclDateTimeFormatter.cpp
20 * @brief This is the implementation file for DateTimeFormatter class.
24 #include <FBaseSysLog.h>
25 #include <FLclDateTimeFormatter.h>
26 #include <FLclNumberFormatter.h>
27 #include "FLcl_DateTimeFormatterImpl.h"
29 using namespace Tizen::Base;
30 using namespace Tizen::Base::Collection;
31 using namespace Tizen::Base::Utility;
33 namespace Tizen { namespace Locales
35 /////////////////////////////////////////////////////////////////////////////////////////////////////
38 DateTimeFormatter::DateTimeFormatter(void)
39 : __pNumberFormat(null)
41 , __pDateTimeFormatterImpl(null)
45 DateTimeFormatter::~DateTimeFormatter(void)
47 delete __pDateTimeFormatterImpl;
51 DateTimeFormatter::CreateDateFormatterN(DateTimeStyle style)
53 if (style == DATE_TIME_STYLE_NONE)
55 style = DATE_TIME_STYLE_DEFAULT;
58 return _DateTimeFormatterImpl::CreateInstanceN(style, DATE_TIME_STYLE_NONE);
63 DateTimeFormatter::CreateDateFormatterN(const Locale& locale, DateTimeStyle style)
65 if (style == DATE_TIME_STYLE_NONE)
67 style = DATE_TIME_STYLE_DEFAULT;
70 return _DateTimeFormatterImpl::CreateInstanceN(locale, style, DATE_TIME_STYLE_NONE);
75 DateTimeFormatter::CreateTimeFormatterN(DateTimeStyle style)
77 if (style == DATE_TIME_STYLE_NONE)
79 style = DATE_TIME_STYLE_DEFAULT;
82 return _DateTimeFormatterImpl::CreateInstanceN(DATE_TIME_STYLE_NONE, style);
87 DateTimeFormatter::CreateTimeFormatterN(const Locale& locale, DateTimeStyle style)
89 if (style == DATE_TIME_STYLE_NONE)
91 style = DATE_TIME_STYLE_DEFAULT;
94 return _DateTimeFormatterImpl::CreateInstanceN(locale, DATE_TIME_STYLE_NONE, style);
99 DateTimeFormatter::CreateDateTimeFormatterN(DateTimeStyle dateStyle, DateTimeStyle timeStyle)
101 if (dateStyle == DATE_TIME_STYLE_NONE)
103 dateStyle = DATE_TIME_STYLE_DEFAULT;
106 if (timeStyle == DATE_TIME_STYLE_NONE)
108 timeStyle = DATE_TIME_STYLE_DEFAULT;
111 return _DateTimeFormatterImpl::CreateInstanceN(dateStyle, timeStyle);
116 DateTimeFormatter::CreateDateTimeFormatterN(const Locale& locale, DateTimeStyle dateStyle, DateTimeStyle timeStyle)
118 if (dateStyle == DATE_TIME_STYLE_NONE)
120 dateStyle = DATE_TIME_STYLE_DEFAULT;
123 if (timeStyle == DATE_TIME_STYLE_NONE)
125 timeStyle = DATE_TIME_STYLE_DEFAULT;
128 return _DateTimeFormatterImpl::CreateInstanceN(locale, dateStyle, timeStyle);
133 DateTimeFormatter::Format(const DateTime& date, String& strBuf) const
135 SysAssertf(__pDateTimeFormatterImpl != null, "Not yet constructed! Construct() should be called before use.");
136 return __pDateTimeFormatterImpl->Format(date, strBuf);
140 DateTimeFormatter::Format(const Calendar& calendar, String& strBuf) const
142 SysAssertf(__pDateTimeFormatterImpl != null, "Not yet constructed! Construct() should be called before use.");
143 return __pDateTimeFormatterImpl->Format(calendar, strBuf);
147 DateTimeFormatter::ApplyPattern(const String& pattern)
149 SysAssertf(__pDateTimeFormatterImpl != null, "Not yet constructed! Construct() should be called before use.");
150 SysTryReturnResult(NID_LCL, !pattern.IsEmpty(), E_INVALID_ARG, "Invalid argument is used. Input pattern is empty");
152 return __pDateTimeFormatterImpl->ApplyPattern(pattern);
157 DateTimeFormatter::GetPattern(void) const
159 SysAssertf(__pDateTimeFormatterImpl != null, "Not yet constructed! Construct() should be called before use.");
160 return __pDateTimeFormatterImpl->GetPattern();
164 const DateTimeSymbols*
165 DateTimeFormatter::GetDateTimeSymbols(void) const
167 SysAssertf(__pDateTimeFormatterImpl != null, "Not yet constructed! Construct() should be called before use.");
168 return __pDateTimeFormatterImpl->GetDateTimeSymbols();
173 DateTimeFormatter::SetDateTimeSymbols(const DateTimeSymbols& newSymbols)
175 SysAssertf(__pDateTimeFormatterImpl != null, "Not yet constructed! Construct() should be called before use.");
176 __pDateTimeFormatterImpl->SetDateTimeSymbols(newSymbols);