[UTC][alarm][Non-ACR][Call tzset() for timezone]
authorSemun Lee <semun.lee@samsung.com>
Tue, 17 Jul 2018 08:15:30 +0000 (17:15 +0900)
committerSemun Lee <semun.lee@samsung.com>
Tue, 17 Jul 2018 08:33:29 +0000 (08:33 +0000)
localtime_r() needs tzset() to be called for calculating
localtime properly.

Change-Id: I70fdfe5da49ed36379141cb470feef1e7fdb95f1
Signed-off-by: Semun Lee <semun.lee@samsung.com>
src/utc/alarm/utc_alarm.c

index a2c7a00..0afb540 100755 (executable)
@@ -13,6 +13,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 //
+#include <time.h>
 #include <glib-object.h>
 #include <string.h>
 #include <app_alarm.h>
@@ -253,6 +254,7 @@ int utc_alarm_schedule_at_date_p(void)
 
        time(&now);
        now += 30;
+       tzset();
        localtime_r(&now, &date);
 
        ret = app_control_create(&app_control);
@@ -293,6 +295,7 @@ int utc_alarm_schedule_at_date_n(void)
 
        time(&now);
        now += 30;
+       tzset();
        localtime_r(&now, &date);
 
        ret = app_control_create(&app_control);
@@ -712,6 +715,7 @@ int utc_alarm_schedule_once_at_date_p(void)
 
        time(&now);
        now += 20;
+       tzset();
        localtime_r(&now, &date);
 
        ret = app_control_create(&app_control);
@@ -752,6 +756,7 @@ int utc_alarm_schedule_once_at_date_n1(void)
        const char *app_id = "org.tizen.helloworld";
 
        time(&now);
+       tzset();
        localtime_r(&now, &date);
        date.tm_mon = 1;
        date.tm_mday = 30;
@@ -830,6 +835,7 @@ int utc_alarm_schedule_once_at_date_n3(void)
 
        time(&now);
        now += 20;
+       tzset();
        localtime_r(&now, &date);
 
        ret = app_control_create(&app_control);
@@ -871,6 +877,7 @@ int utc_alarm_schedule_with_recurrence_week_flag_p(void)
        int ret = ALARM_ERROR_NONE;
 
        time(&now);
+       tzset();
        localtime_r(&now, &date);
        date.tm_sec += 3;
 
@@ -911,6 +918,7 @@ int utc_alarm_schedule_with_recurrence_week_flag_n1(void)
        int ret = ALARM_ERROR_NONE;
 
        time(&now);
+       tzset();
        localtime_r(&now, &date);
        date.tm_sec += 3;
 
@@ -943,6 +951,7 @@ int utc_alarm_schedule_with_recurrence_week_flag_n2(void)
        int ret = ALARM_ERROR_NONE;
 
        time(&now);
+       tzset();
        localtime_r(&now, &date);
        date.tm_mon = 1;
        date.tm_mday = 30;
@@ -985,6 +994,7 @@ int utc_alarm_schedule_with_recurrence_week_flag_n3(void)
        int ret = ALARM_ERROR_NONE;
 
        time(&now);
+       tzset();
        localtime_r(&now, &date);
        date.tm_sec += 3;
 
@@ -1029,6 +1039,7 @@ int utc_alarm_get_scheduled_recurrence_week_flag_p(void)
        int ret = ALARM_ERROR_NONE;
 
        time(&now);
+       tzset();
        localtime_r(&now, &date);
        date.tm_sec += 3;
 
@@ -1458,6 +1469,7 @@ int utc_alarm_schedule_noti_once_at_date_p(void)
 
        time(&now);
        now += 5;
+       tzset();
        localtime_r(&now, &date);
 
        noti = notification_create(NOTIFICATION_TYPE_NOTI);
@@ -1504,6 +1516,7 @@ int utc_alarm_schedule_noti_once_at_date_n1(void)
 
        time(&now);
        now += 20;
+       tzset();
        localtime_r(&now, &date);
 
        noti = notification_create(NOTIFICATION_TYPE_NOTI);
@@ -1542,6 +1555,7 @@ int utc_alarm_schedule_noti_once_at_date_n2(void)
 
        time(&now);
        now += 20;
+       tzset();
        localtime_r(&now, &date);
 
        ret = alarm_schedule_noti_once_at_date(NULL, &date, &tid);
@@ -1758,6 +1772,7 @@ int utc_alarm_schedule_noti_with_recurrence_week_flag_p(void)
 
        time(&now);
        now += 5;
+       tzset();
        localtime_r(&now, &date);
 
        noti = notification_create(NOTIFICATION_TYPE_NOTI);
@@ -1815,6 +1830,7 @@ int utc_alarm_schedule_noti_with_recurrence_week_flag_n1(void)
        assert_eq_with_exit(ret, NOTIFICATION_ERROR_NONE);
 
        time(&now);
+       tzset();
        localtime_r(&now, &date);
        date.tm_sec += 3;
 
@@ -1845,6 +1861,7 @@ int utc_alarm_schedule_noti_with_recurrence_week_flag_n2(void)
        int tid;
 
        time(&now);
+       tzset();
        localtime_r(&now, &date);
        date.tm_sec += 3;
 
@@ -2085,6 +2102,7 @@ int utc_alarm_update_date_p(void)
 
        time(&now);
        now += 20;
+       tzset();
        localtime_r(&now, &date);
        now += 20;
        localtime_r(&now, &date2);
@@ -2132,6 +2150,7 @@ int utc_alarm_update_date_n1(void)
 
        time(&now);
        now += 20;
+       tzset();
        localtime_r(&now, &date);
 
        ret = app_control_create(&app_control);
@@ -2173,6 +2192,7 @@ int utc_alarm_update_date_n2(void)
 
        time(&now);
        now += 20;
+       tzset();
        localtime_r(&now, &date);
 
        ret = alarm_update_date(0, &date);
@@ -2202,6 +2222,7 @@ int utc_alarm_update_date_n3(void)
        const char *app_id = "org.tizen.service-with-bg-category";
        time(&now);
        now += 20;
+       tzset();
        localtime_r(&now, &date);
 
        ret = app_control_create(&app_control);
@@ -2346,6 +2367,7 @@ int utc_alarm_update_week_flag_p(void)
        int ret = ALARM_ERROR_NONE;
 
        time(&now);
+       tzset();
        localtime_r(&now, &date);
        date.tm_sec += 3;
 
@@ -2390,6 +2412,7 @@ int utc_alarm_update_week_flag_n1(void)
        int ret2 = ALARM_ERROR_NONE;
 
        time(&now);
+       tzset();
        localtime_r(&now, &date);
        date.tm_sec += 3;