summaryrefslogtreecommitdiff
path: root/lib-apps-common/inc/I18n/DateFormatter.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib-apps-common/inc/I18n/DateFormatter.h')
-rw-r--r--lib-apps-common/inc/I18n/DateFormatter.h61
1 files changed, 61 insertions, 0 deletions
diff --git a/lib-apps-common/inc/I18n/DateFormatter.h b/lib-apps-common/inc/I18n/DateFormatter.h
new file mode 100644
index 0000000..81bdd80
--- /dev/null
+++ b/lib-apps-common/inc/I18n/DateFormatter.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef I18N_DATE_FORMATTER_H
+#define I18N_DATE_FORMATTER_H
+
+#include "I18n/String.h"
+#include <system_settings.h>
+
+namespace I18n
+{
+ /**
+ * @brief Performs locale-dependent date formatting based on pattern skeleton.
+ */
+ class EXPORT_API DateFormatter
+ {
+ public:
+ /**
+ * @brief Create formatter.
+ * @param[in] skeleton Date pattern skeleton
+ */
+ explicit DateFormatter(const char *skeleton);
+ DateFormatter(const DateFormatter &that) = delete;
+ DateFormatter(DateFormatter &&that);
+ ~DateFormatter();
+
+ DateFormatter & operator=(const DateFormatter &that) = delete;
+ DateFormatter & operator=(DateFormatter &&that);
+
+ /**
+ * @brief Create string representation for given date.
+ * @param[in] date Date to format
+ * @return Formatted date.
+ */
+ std::string formatDate(const tm &date);
+
+ private:
+ void initialize();
+ void initializePattern(const char *lang);
+ void onLocaleChanged(system_settings_key_e key);
+
+ String m_Skeleton;
+ String m_Pattern;
+ i18n_udate_format_h m_Formatter;
+ };
+}
+
+#endif /* I18N_DATE_FORMATTER_H */