[Base-utils][Timezone] Detect host timezone function added. 22/88022/14
authorRafal Szczekutek <r.szczekutek@samsung.com>
Fri, 14 Oct 2016 11:01:00 +0000 (13:01 +0200)
committerhyunjee Kim <hj0426.kim@samsung.com>
Thu, 3 Nov 2016 00:22:15 +0000 (17:22 -0700)
Change-Id: I801c263a43c651ccd5d7ceeb9ba4b85f61b125dd
Signed-off-by: Tomasz Bochenski <t.bochenski@partner.samsung.com>
Signed-off-by: Tomasz Bochenski <t.bochenski@samsung.com>
Signed-off-by: Rafal Szczekutek <r.szczekutek@samsung.com>
Signed-off-by: Tomasz Bochenski <t.bochenski@samsung.com>
src/include/cleaned/utils_i18n_timezone.h
src/include/deprecated/utils_i18n_timezone.h
src/include/utils_i18n.h
src/include/utils_i18n_timezone.h
src/include/utils_i18n_ucalendar.h
src/utils_i18n_timezone.cpp

index aa11fc8..f8ddec0 100644 (file)
@@ -211,6 +211,9 @@ int i18n_timezone_get_equivalent_id(const char *timezone_id, int32_t index, char
  *
  * This function determines the default timezone by querying the system once and storing the
  * obtained timezone as default until the application terminates.
+ *
+ * To query the system for the current timezone, use i18n_timezone_detect_host_timezone().
+ *
  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
  *
  * @param[out] timezone A default i18n_timezone_h. Clients are responsible for deleting the time zone object returned.
@@ -444,6 +447,22 @@ int i18n_timezone_clone(i18n_timezone_h timezone, i18n_timezone_h *clone);
  */
 int i18n_timezone_get_dst_savings(i18n_timezone_h timezone, int32_t *dst_savings);
 
+/**
+ * @brief Creates an #i18n_timezone_h detected from the current host system configuration.
+ * @details This function does not change the default time zone and does not update the current
+ * ICU's default. It may return a different #i18n_timezone_h from the one returned by
+ * i18n_timezone_create_default().
+ * @since_tizen 3.0
+ *
+ * @param[out] timezone A new instance of #i18n_timezone_h detected from the current host system
+ * configuration. Users are responsible for deleting the returned time zone object with
+ * i18n_timezone_destroy().
+ *
+ * @retval #I18N_ERROR_NONE Successful
+ * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter
+ */
+int i18n_timezone_detect_host_timezone(i18n_timezone_h *timezone);
+
 #ifdef __cplusplus
 }
 #endif
index f18ecde..8f32bec 100644 (file)
@@ -212,6 +212,9 @@ int i18n_timezone_get_equivalent_id(const char *timezone_id, int32_t index, char
  *
  * This function determines the default timezone by querying the system once and storing the
  * obtained timezone as default until the application terminates.
+ *
+ * To query the system for the current timezone, use i18n_timezone_detect_host_timezone().
+ *
  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
  *
  * @param[out] timezone A default i18n_timezone_h. Clients are responsible for deleting the time zone object returned.
@@ -460,6 +463,22 @@ int i18n_timezone_clone(i18n_timezone_h timezone, i18n_timezone_h *clone);
  */
 int i18n_timezone_get_dst_savings(i18n_timezone_h timezone, int32_t *dst_savings);
 
+/**
+ * @brief Creates an #i18n_timezone_h detected from the current host system configuration.
+ * @details This function does not change the default time zone and does not update the current
+ * ICU's default. It may return a different #i18n_timezone_h from the one returned by
+ * i18n_timezone_create_default().
+ * @since_tizen 3.0
+ *
+ * @param[out] timezone A new instance of #i18n_timezone_h detected from the current host system
+ * configuration. Users are responsible for deleting the returned time zone object with
+ * i18n_timezone_destroy().
+ *
+ * @retval #I18N_ERROR_NONE Successful
+ * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter
+ */
+int i18n_timezone_detect_host_timezone(i18n_timezone_h *timezone);
+
 #ifdef __cplusplus
 }
 #endif
index 0376423..f152e70 100644 (file)
@@ -350,6 +350,11 @@ extern "C" {
  *       <td>getDSTSavings</td>
  * </tr>
  * <tr>
+ *    <td>@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE</td>
+ *    <td>#i18n_timezone_detect_host_timezone</td>
+ *    <td>detectHostTimeZone</td>
+ * </tr>
+ * <tr>
  *       <td>@ref CAPI_BASE_UTILS_I18N_UENUMERATION_MODULE</td>
  *       <td>#i18n_uenumeration_destroy</td>
  *       <td>uenum_close</td>
index ddedd74..09d3e72 100644 (file)
@@ -211,6 +211,9 @@ int i18n_timezone_get_equivalent_id(const char *timezone_id, int32_t index, char
  *
  * This function determines the default timezone by querying the system once and storing the
  * obtained timezone as default until the application terminates.
+ *
+ * To query the system for the current timezone, use i18n_timezone_detect_host_timezone().
+ *
  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
  *
  * @param[out] timezone A default i18n_timezone_h. Clients are responsible for deleting the time zone object returned.
@@ -459,6 +462,22 @@ int i18n_timezone_clone(i18n_timezone_h timezone, i18n_timezone_h *clone);
  */
 int i18n_timezone_get_dst_savings(i18n_timezone_h timezone, int32_t *dst_savings);
 
+/**
+ * @brief Creates an #i18n_timezone_h detected from the current host system configuration.
+ * @details This function does not change the default time zone and does not update the current
+ * ICU's default. It may return a different #i18n_timezone_h from the one returned by
+ * i18n_timezone_create_default().
+ * @since_tizen 3.0
+ *
+ * @param[out] timezone A new instance of #i18n_timezone_h detected from the current host system
+ * configuration. Users are responsible for deleting the returned time zone object with
+ * i18n_timezone_destroy().
+ *
+ * @retval #I18N_ERROR_NONE Successful
+ * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter
+ */
+int i18n_timezone_detect_host_timezone(i18n_timezone_h *timezone);
+
 #ifdef __cplusplus
 }
 #endif
index 181eb18..6e930d8 100644 (file)
@@ -477,14 +477,18 @@ int i18n_ucalendar_country_timezones_create(const char *country, i18n_uenumerati
  *      reflect the change, i.e. the returned time zone will be the same as for the first function
  *      call.
  *
+ *      To query the system for the current timezone, use i18n_timezone_detect_host_timezone()
+ *      from the Timezone module.
+ *
  *      The default time zone may be changed with i18n_ucalendar_set_default_timezone()
  *      or with the i18n Timezone API.
+ *
  * @remarks The specific error code can be obtained using the get_last_result()
  *      method. Error codes are described in #i18n_error_code_e description.
  * @since_tizen 2.3.1
  *
  * @param[out] result A buffer to receive the result, or @c NULL
- * @param[in]     result_capacity The capacity of the @c result buffer
+ * @param[in]  result_capacity The capacity of the @c result buffer
  *
  * @return The @c result string length, not including the terminating @c NULL.
  * @exception #I18N_ERROR_NONE Successful
index e72d085..23b4494 100755 (executable)
@@ -447,3 +447,12 @@ int i18n_timezone_get_dst_savings(i18n_timezone_h timezone, int32_t *dst_savings
 
     return I18N_ERROR_NONE;
 }
+
+int i18n_timezone_detect_host_timezone(i18n_timezone_h *timezone)
+{
+    retv_if(timezone == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+    *timezone = TimeZone::detectHostTimeZone();
+
+    return I18N_ERROR_NONE;
+}