[base-utils][ACR-1202][DateInterval] Module implementation 89/172889/8 accepted/tizen/unified/20180426.062448 submit/tizen/20180425.043137
authorTomasz Bocheński <t.bochenski@partner.samsung.com>
Fri, 16 Mar 2018 12:30:46 +0000 (13:30 +0100)
committerhyunjee Kim <hj0426.kim@samsung.com>
Wed, 25 Apr 2018 04:21:21 +0000 (04:21 +0000)
Change-Id: I9cc18fe990e8f594c89b51425e797c168991ae4d
Signed-off-by: Tomasz Bocheński <t.bochenski@partner.samsung.com>
src/CMakeLists.txt
src/include/utils_i18n.h
src/include/utils_i18n_date_interval.h [new file with mode: 0644]
src/include/utils_i18n_types.h
src/utils_i18n_date_interval.cpp [new file with mode: 0644]

index 3c8df4e..5e9cae8 100755 (executable)
@@ -43,6 +43,7 @@ SET(BASEUTILS_SRCS
     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}
@@ -93,5 +94,6 @@ INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${INC_DIR}/utils_i18n_uchar_iter.h DES
 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)
index 54184fb..28ca174 100644 (file)
@@ -48,6 +48,7 @@
 #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
@@ -89,6 +90,7 @@ extern "C" {
  *       - 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.
@@ -235,6 +237,10 @@ extern "C" {
  *     <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
@@ -3916,6 +3922,36 @@ extern "C" {
  *    <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>
  */
 
diff --git a/src/include/utils_i18n_date_interval.h b/src/include/utils_i18n_date_interval.h
new file mode 100644 (file)
index 0000000..9d4d580
--- /dev/null
@@ -0,0 +1,143 @@
+/*
+ * 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__ */
index e74f9cb..c8ace19 100644 (file)
@@ -4402,6 +4402,22 @@ typedef void *i18n_immutable_idx_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,
diff --git a/src/utils_i18n_date_interval.cpp b/src/utils_i18n_date_interval.cpp
new file mode 100644 (file)
index 0000000..0b18be1
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * 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;
+}