2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @author Tae-Jeong Lee (taejeong.lee@samsung.com)
21 #include "TimeUtils.h"
22 #include <unicode/ucal.h>
24 namespace WrtDeviceApis {
28 struct tm* localtime_r(long long int* timep, struct tm* result)
30 UErrorCode status = U_ZERO_ERROR;
33 if( !result || !timep )
38 cal = ucal_open(NULL, 0, NULL, UCAL_DEFAULT, &status);
45 ucal_setMillis(cal, (*timep * (double)1000.0), &status);
47 result->tm_sec = ucal_get(cal, UCAL_SECOND, &status);
48 result->tm_min = ucal_get(cal, UCAL_MINUTE, &status);
49 result->tm_hour = ucal_get(cal, UCAL_HOUR, &status);
50 result->tm_mday = ucal_get(cal, UCAL_DAY_OF_MONTH, &status);
51 result->tm_mon = ucal_get(cal, UCAL_MONTH, &status);
52 result->tm_year = ucal_get(cal, UCAL_YEAR, &status);
53 result->tm_wday = ucal_get(cal, UCAL_DAY_OF_WEEK, &status);
54 result->tm_yday = ucal_get(cal, UCAL_DAY_OF_YEAR, &status);
55 result->tm_isdst= ucal_get(cal, UCAL_DST_OFFSET, &status);