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 {
27 struct tm* localtime_r(long long int* timep, struct tm* result)
29 UErrorCode status = U_ZERO_ERROR;
32 if (!result || !timep) {
36 cal = ucal_open(NULL, 0, NULL, UCAL_DEFAULT, &status);
38 if (U_FAILURE(status)) {
42 ucal_setMillis(cal, (*timep * (double)1000.0), &status);
44 result->tm_sec = ucal_get(cal, UCAL_SECOND, &status);
45 result->tm_min = ucal_get(cal, UCAL_MINUTE, &status);
46 result->tm_hour = ucal_get(cal, UCAL_HOUR, &status);
47 result->tm_mday = ucal_get(cal, UCAL_DAY_OF_MONTH, &status);
48 result->tm_mon = ucal_get(cal, UCAL_MONTH, &status);
49 result->tm_year = ucal_get(cal, UCAL_YEAR, &status);
50 result->tm_wday = ucal_get(cal, UCAL_DAY_OF_WEEK, &status);
51 result->tm_yday = ucal_get(cal, UCAL_DAY_OF_YEAR, &status);
52 result->tm_isdst = ucal_get(cal, UCAL_DST_OFFSET, &status);
56 if (U_FAILURE(status)) {