95c21016744c7c881fc2c7e215dac0ea8408f513
[apps/home/clock.git] / alarm / src / alarm_fwk_icu.c
1 /*
2   * Copyright 2012  Samsung Electronics Co., Ltd
3   * 
4   * Licensed under the Flora License, Version 1.0 (the "License");
5   * you may not use this file except in compliance with the License.
6   * You may obtain a copy of the License at
7   * 
8   *     http://www.tizenopensource.org/license
9   * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16
17 #include "alarm_fwk_icu.h"
18
19 /**********************************************************************
20 ******************Global val , static global val*************************************
21 ***********************************************************************/
22 //
23 char *time_pattern[2] = {
24         STRING_ALARM_TIMEPATTEN_A,
25         STRING_ALARM_TIMEPATTEN,
26 };
27
28 /**********************************************************************
29 ******************Local function ref*************************************
30 ***********************************************************************/
31 //
32 static int __get_pattern_time(char *pattern, int num, CLK_TIME_FORMAT timeStyle)
33 {
34         retvm_if(!pattern, FAILED, "pattern null");
35         retvm_if(num <= 0, FAILED, "num<=0");
36         snprintf(pattern, num * sizeof(char) - 1, "%s",
37                  time_pattern[timeStyle]);
38         //CLK_INFO_PURPLE("pattern=%s",pattern);
39         return 0;
40 }
41
42 /**********************************************************************
43 ******************Global function ref*************************************
44 ***********************************************************************/
45 //
46 char *alarm_icu_get_time_str(time_t input_time, char *timezone,
47                              CLK_TIME_FORMAT *pTimeFormat)
48 {
49         static char string_icu_time[BUF_SIZE_32] = { 0 };
50         char pattern[MAX_PATTERN_LENGHT] = { 0 };
51         CLK_TIME_FORMAT time_format;
52         time_format = clk_fwk_icu_time_format_get();
53         __get_pattern_time(pattern, MAX_PATTERN_LENGHT, time_format);
54         //CLK_INFO_PURPLE("pattern=%s",pattern);
55         clk_fwk_icu_get_data(input_time, string_icu_time, BUF_SIZE_32, NULL,
56                              pattern, MAX_PATTERN_LENGHT, timezone);
57         // splice time string to result string
58         if (pTimeFormat) {
59                 *pTimeFormat = time_format;
60         }
61         return string_icu_time;
62 }