7409981c71b4a6ebb690f16129b200057bcc3854
[apps/core/preloaded/calendar.git] / common / common.c
1
2 /*
3   *
4   *  Copyright 2012  Samsung Electronics Co., Ltd
5   *
6   *  Licensed under the Flora License, Version 1.0 (the "License");
7   *  you may not use this file except in compliance with the License.
8   *  You may obtain a copy of the License at
9   *
10   *       http://floralicense.org/license/
11   *
12   *  Unless required by applicable law or agreed to in writing, software
13   *  distributed under the License is distributed on an "AS IS" BASIS,
14   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   *  See the License for the specific language governing permissions and
16   *  limitations under the License.
17   */
18
19
20 #include "cld.h"
21
22 #ifdef CAL_TIMECHECK
23 double cal_set_start_time(void)
24 {
25         struct timeval tv;
26         double curtime;
27
28         gettimeofday(&tv, NULL);
29         curtime = tv.tv_sec * 1000 + (double)tv.tv_usec/1000;
30         return curtime;
31 }
32
33 double cal_exec_time(double start, double correction)
34 {
35         double end = cal_set_start_time();
36         return (end - start - correction);
37 }
38
39 double cal_init_time(double correction)
40 {
41         double temp_t;
42         temp_t = cal_set_start_time();
43         return cal_exec_time(temp_t, correction);
44 }
45 #endif//CAL_TIMECHECK