From 18e8b27f20503083b8be7c35aa15de02d0894a33 Mon Sep 17 00:00:00 2001 From: Rafal Szczekutek Date: Fri, 14 Oct 2016 13:01:00 +0200 Subject: [PATCH] [Base-utils][Timezone] Detect host timezone function added. Change-Id: I801c263a43c651ccd5d7ceeb9ba4b85f61b125dd Signed-off-by: Tomasz Bochenski Signed-off-by: Tomasz Bochenski Signed-off-by: Rafal Szczekutek Signed-off-by: Tomasz Bochenski --- src/include/cleaned/utils_i18n_timezone.h | 19 +++++++++++++++++++ src/include/deprecated/utils_i18n_timezone.h | 19 +++++++++++++++++++ src/include/utils_i18n.h | 5 +++++ src/include/utils_i18n_timezone.h | 19 +++++++++++++++++++ src/include/utils_i18n_ucalendar.h | 6 +++++- src/utils_i18n_timezone.cpp | 9 +++++++++ 6 files changed, 76 insertions(+), 1 deletion(-) diff --git a/src/include/cleaned/utils_i18n_timezone.h b/src/include/cleaned/utils_i18n_timezone.h index aa11fc8..f8ddec0 100644 --- a/src/include/cleaned/utils_i18n_timezone.h +++ b/src/include/cleaned/utils_i18n_timezone.h @@ -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 diff --git a/src/include/deprecated/utils_i18n_timezone.h b/src/include/deprecated/utils_i18n_timezone.h index f18ecde..8f32bec 100644 --- a/src/include/deprecated/utils_i18n_timezone.h +++ b/src/include/deprecated/utils_i18n_timezone.h @@ -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 diff --git a/src/include/utils_i18n.h b/src/include/utils_i18n.h index 0376423..f152e70 100644 --- a/src/include/utils_i18n.h +++ b/src/include/utils_i18n.h @@ -350,6 +350,11 @@ extern "C" { * getDSTSavings * * + * @ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE + * #i18n_timezone_detect_host_timezone + * detectHostTimeZone + * + * * @ref CAPI_BASE_UTILS_I18N_UENUMERATION_MODULE * #i18n_uenumeration_destroy * uenum_close diff --git a/src/include/utils_i18n_timezone.h b/src/include/utils_i18n_timezone.h index ddedd74..09d3e72 100644 --- a/src/include/utils_i18n_timezone.h +++ b/src/include/utils_i18n_timezone.h @@ -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 diff --git a/src/include/utils_i18n_ucalendar.h b/src/include/utils_i18n_ucalendar.h index 181eb18..6e930d8 100644 --- a/src/include/utils_i18n_ucalendar.h +++ b/src/include/utils_i18n_ucalendar.h @@ -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 diff --git a/src/utils_i18n_timezone.cpp b/src/utils_i18n_timezone.cpp index e72d085..23b4494 100755 --- a/src/utils_i18n_timezone.cpp +++ b/src/utils_i18n_timezone.cpp @@ -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; +} -- 2.7.4