utils_i18n_plural_rules.cpp
utils_i18n_plural_format.cpp
utils_i18n_immutable_idx.cpp
+ utils_i18n_date_interval.cpp
)
ADD_LIBRARY(${target_name} SHARED ${BASEUTILS_SRCS}
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${INC_DIR}/utils_i18n_plural_rules.h DESTINATION ${INCLUDE_INSTALL_DIR}/base)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${INC_DIR}/utils_i18n_plural_format.h DESTINATION ${INCLUDE_INSTALL_DIR}/base)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${INC_DIR}/utils_i18n_immutable_idx.h DESTINATION ${INCLUDE_INSTALL_DIR}/base)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${INC_DIR}/utils_i18n_date_interval.h DESTINATION ${INCLUDE_INSTALL_DIR}/base)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${INC_DIR}/utils_i18n.h DESTINATION ${INCLUDE_INSTALL_DIR}/base)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${pc_name}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
#include <utils_i18n_plural_rules.h>
#include <utils_i18n_plural_format.h>
#include <utils_i18n_immutable_idx.h>
+#include <utils_i18n_date_interval.h>
/**
* @file utils_i18n.h
* - plural rules
* - plural format
* - immutable_idx
+ * - date interval
*
* This module provides flexible generation of number or date format patterns and helps you format and parse dates/number for any locale.
* The i18n module provides various features based on data from ICU. The following table shows the version of ICU used in each Tizen platform.
* <td>@ref CAPI_BASE_UTILS_I18N_IMMUTABLE_IDX_MODULE</td>
* <td>The Immutable_idx is immutable, thread-safe version of Alpha_idx.</td>
* </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_DATE_INTERVAL_MODULE</td>
+ * <td>Date interval represents a date interval.</td>
+ * </tr>
* </table>
*
* @section CAPI_BASE_UTILS_I18N_MODULE_MAPPING_TABLE Mapping Table
* <td>#i18n_immutable_idx_get_bucket_label_type</td>
* <td>getLabelType</td>
* </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_DATE_INTERVAL_MODULE</td>
+ * <td>#i18n_date_interval_create</td>
+ * <td>DateInterval</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_DATE_INTERVAL_MODULE</td>
+ * <td>#i18n_date_interval_destroy</td>
+ * <td>~DateInterval </td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_DATE_INTERVAL_MODULE</td>
+ * <td>#i18n_date_interval_clone</td>
+ * <td>clone</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_DATE_INTERVAL_MODULE</td>
+ * <td>#i18n_date_interval_get_from_date</td>
+ * <td>getFromDate</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_DATE_INTERVAL_MODULE</td>
+ * <td>#i18n_date_interval_get_to_date</td>
+ * <td>getToDate</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_DATE_INTERVAL_MODULE</td>
+ * <td>#i18n_date_interval_equals</td>
+ * <td>operator==</td>
+ * </tr>
* </table>
*/
--- /dev/null
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 __UTILS_I18N_DATE_INTERVAL_H__
+#define __UTILS_I18N_DATE_INTERVAL_H__
+
+#include <utils_i18n_types.h>
+
+/**
+ * @file utils_i18n_date_interval.h
+ * @version 0.1
+ * @brief utils_i18n_date_interval
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @ingroup CAPI_BASE_UTILS_I18N_MODULE
+ * @defgroup CAPI_BASE_UTILS_I18N_DATE_INTERVAL_MODULE Date Interval
+ * @brief Date Interval represents a date interval.
+ * @section CAPI_BASE_UTILS_I18N_DATE_INTERVAL_MODULE_HEADER Required Header
+ * \#include <utils_i18n.h>
+ *
+ * @section CAPI_BASE_UTILS_I18N_DATE_INTERVAL_MODULE_OVERVIEW Overview
+ * @details The module represents a date interval.
+ */
+
+/**
+ * @addtogroup CAPI_BASE_UTILS_I18N_DATE_INTERVAL_MODULE
+ * @{
+ */
+
+/**
+ * @brief Creates a date interval object.
+ * @since_tizen 5.0
+ * @remarks The created object should be released by the caller with the
+ * i18n_date_interval_destroy() function.
+ *
+ * @param[in] from_date The start date of the date interval
+ * @param[in] to_date The end date of the date interval
+ * @param[out] date_interval The created date interval object
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #I18N_ERROR_NONE Successful
+ * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter
+ * @retval #I18N_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int i18n_date_interval_create(i18n_udate from_date, i18n_udate to_date, i18n_date_interval_h *date_interval);
+
+/**
+ * @brief Destroys the date interval object.
+ * @since_tizen 5.0
+ *
+ * @param[in] date_interval The date interval to be destroyed
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #I18N_ERROR_NONE Successful
+ * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter
+ */
+int i18n_date_interval_destroy(i18n_date_interval_h date_interval);
+
+/**
+ * @brief Clones the date interval object.
+ * @since_tizen 5.0
+ * @remarks The cloned object should be released by the caller with the
+ * i18n_date_interval_destroy() function.
+ *
+ * @param[in] date_interval The date interval to be cloned
+ * @param[out] clone The clone of the given @a date_interval object
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #I18N_ERROR_NONE Successful
+ * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter
+ * @retval #I18N_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int i18n_date_interval_clone(i18n_date_interval_h date_interval, i18n_date_interval_h *clone);
+
+/**
+ * @brief Gets the 'from date' from a given date interval object.
+ * @since_tizen 5.0
+ *
+ * @param[in] date_interval The date interval object
+ * @param[out] from_date The 'from date' value
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #I18N_ERROR_NONE Successful
+ * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter
+ */
+int i18n_date_interval_get_from_date(i18n_date_interval_h date_interval, i18n_udate *from_date);
+
+/**
+ * @brief Gets the 'to date' from a given date interval object.
+ * @since_tizen 5.0
+ *
+ * @param[in] date_interval The date interval object
+ * @param[out] to_date The 'to date' value
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #I18N_ERROR_NONE Successful
+ * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter
+ */
+int i18n_date_interval_get_to_date(i18n_date_interval_h date_interval, i18n_udate *to_date);
+
+/**
+ * @brief Compares two date interval objects.
+ * @since_tizen 5.0
+ *
+ * @param[in] date_interval_1 The first date interval object
+ * @param[in] date_interval_2 The second date interval object
+ * @param[out] equals A flag set to @c true if given objects are equal,
+ * or @c false otherwise.
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #I18N_ERROR_NONE Successful
+ * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter
+ */
+int i18n_date_interval_equals(i18n_date_interval_h date_interval_1, i18n_date_interval_h date_interval_2,
+ i18n_ubool *equals);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __UTILS_I18N_DATE_INTERVAL_H__ */
*/
/**
+* @addtogroup CAPI_BASE_UTILS_I18N_DATE_INTERVAL_MODULE
+* @{
+*/
+
+/**
+ * @brief An #i18n_date_interval_h handle.
+ * @details Use i18n_date_interval_* functions to operate on #i18n_date_interval_h objects.
+ * @since_tizen 5.0
+ */
+typedef void *i18n_date_interval_h;
+
+/**
+ * @}
+ */
+
+/**
* @brief This value is intended for sentinel values for APIs that (take or) return
* single code points (#i18n_uchar32).
* @details It is outside of the Unicode code point range 0..0x10ffff. For example,
--- /dev/null
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ */
+
+#include <utils_i18n_date_interval.h>
+#include <utils_i18n_private.h>
+
+#include <unicode/dtintrv.h>
+
+int i18n_date_interval_create(i18n_udate from_date, i18n_udate to_date, i18n_date_interval_h *date_interval)
+{
+ retv_if(date_interval == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ *date_interval = new DateInterval(from_date, to_date);
+ retv_if(*date_interval == NULL, I18N_ERROR_OUT_OF_MEMORY);
+
+ return I18N_ERROR_NONE;
+}
+
+int i18n_date_interval_destroy(i18n_date_interval_h date_interval)
+{
+ retv_if(date_interval == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ delete ((DateInterval *) date_interval);
+
+ return I18N_ERROR_NONE;
+}
+
+int i18n_date_interval_clone(i18n_date_interval_h date_interval, i18n_date_interval_h *clone)
+{
+ retv_if(date_interval == NULL, I18N_ERROR_INVALID_PARAMETER);
+ retv_if(clone == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ *clone = ((DateInterval *) date_interval)->clone();
+
+ return I18N_ERROR_NONE;
+}
+
+int i18n_date_interval_get_from_date(i18n_date_interval_h date_interval, i18n_udate *from_date)
+{
+ retv_if(date_interval == NULL, I18N_ERROR_INVALID_PARAMETER);
+ retv_if(from_date == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ *from_date = ((DateInterval *) date_interval)->getFromDate();
+
+ return I18N_ERROR_NONE;
+}
+
+int i18n_date_interval_get_to_date(i18n_date_interval_h date_interval, i18n_udate *to_date)
+{
+ retv_if(date_interval == NULL, I18N_ERROR_INVALID_PARAMETER);
+ retv_if(to_date == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ *to_date = ((DateInterval *) date_interval)->getToDate();
+
+ return I18N_ERROR_NONE;
+}
+
+int i18n_date_interval_equals(i18n_date_interval_h date_interval_1, i18n_date_interval_h date_interval_2,
+ i18n_ubool *equals)
+{
+ retv_if(date_interval_1 == NULL, I18N_ERROR_INVALID_PARAMETER);
+ retv_if(date_interval_2 == NULL, I18N_ERROR_INVALID_PARAMETER);
+ retv_if(equals == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ *equals = (*((DateInterval *) date_interval_1)) == (*((DateInterval *) date_interval_2));
+
+ return I18N_ERROR_NONE;
+}