internal_time_utils.h File Reference

Time services - usefull wrappers of system time services. More...

#include <time.h>

Functions

time_t internal_get_time (void)
int internal_set_time (time_t t)
int internal_get_dst (time_t tick)
int internal_get_utc_offset (time_t tick, int dst)
int internal_set_tz (const char *tz)
void internal_tz_set (char **old, const char *tz)
void internal_tz_res (char **old)
time_t internal_mktime_in (struct tm *tm, const char *tz)
struct tm * internal_localtime_r_in (struct tm *utc_tm, struct tm *result, const char *tz)
int internal_setenv_tz (const char *tzname)
int internal_tz_cmp (const char *firstTZName, const char *secondTZName)
int internal_check_timezone (const char *zone)


Detailed Description

Utilities above system time servises.

Copyright (C) 2008 Nokia. All rights reserved.

Author:
Simo Piiroinen <simo.piiroinen@nokia.com>

Raimo Vuonnala <raimo.vuonnala@nokia.com>


Function Documentation

time_t internal_get_time ( void   ) 

Get current time. Returns system (in product mode) or fake (if macro USE_FAKE_TIME is enabled) time.

Returns:
count of ticks from Epoch
Get current time. Returns system time.

Returns:
count of ticks from Epoch

Referenced by dump_date(), handle_alarm(), handle_csd_net_time_change(), internal_get_dst(), internal_tz_cmp(), and server_get_time_cb().

int internal_set_time ( time_t  t  ) 

Set current time. Update system (in product mode) or fake (if macro USE_FAKE_TIME is enabled) time. It does not update system time in fake mode but clockd can't see it.

Parameters:
t count of ticks from Epoch to be set as current time
Returns:
0 if no error, error code otherwise
Set current time. Update system time.

Parameters:
t count of ticks from Epoch to be set as current time
Returns:
0 if no error, error code otherwise

Referenced by server_set_time().

int internal_get_dst ( time_t  tick  ) 

Get daylight state

Parameters:
tick Current time, 0 if not known
Returns:
0 if no DST, 1 if DST

Referenced by dump_date(), handle_alarm(), internal_get_utc_offset(), server_init(), and server_send_time_change_indication().

int internal_get_utc_offset ( time_t  tick,
int  dst 
)

Get UTC offset

Parameters:
tick Current time, 0 if not known
dst nonzero if daylight is counted in
Returns:
Offset in secs

Referenced by dump_date().

int internal_set_tz ( const char *  tz  ) 

Set system timezone

Parameters:
tz Timezone
Returns:
0 if OK, !=0 if fails

Referenced by server_init(), and server_set_tz_cb().

void internal_tz_set ( char **  old,
const char *  tz 
)

Utility function used to set timezone temporarily. It is needed to calculate time in timezone different from system one. It is used in pair with internal_tz_res which restores previous timezone.

Parameters:
old Pointer to store current timezone name until internal_tz_res called Note: the memory is allocated for this purpose. It will be freed automatically inside internal_tz_res.
tz Temporal timezone

Referenced by handle_csd_net_time_change(), internal_localtime_r_in(), and internal_mktime_in().

void internal_tz_res ( char **  old  ) 

Utility function used to restore previous timezone changed by internal_tz_set.

Parameters:
old Pointer to timezone name which was provided by internal_tz_set Note: the memory allocated to store the name is freed after call of internal_tz_res the pointer becomes 0 at the end.
Utility function used to restore previous timezone changed by internal_tz_set.

Parameters:
old Pointer to timezone name which was provided by internal_tz_set Note: the memory allocated to store the name is freed after call of internal_tz_res. the pointer becomes 0 at the end.

Referenced by handle_csd_net_time_change(), internal_localtime_r_in(), and internal_mktime_in().

time_t internal_mktime_in ( struct tm *  tm,
const char *  tz 
)

Make time_t from struct tm. Like mktime() but timezone can be given.

Parameters:
tm See mktime
tz Time zone variable. All formats that glibc supports can be given. NULL if current zone is used.
See http://www.gnu.org/software/libtool/manual/libc/TZ-Variable.html
Returns:
Time since Epoch or 0 if error

Referenced by handle_csd_net_time_change(), and internal_localtime_r_in().

struct tm* internal_localtime_r_in ( struct tm *  utc_tm,
struct tm *  result,
const char *  tz 
) [read]

Converts UTC time into local time for given timezone

Parameters:
utc_tm UTC time in tm structure
result pointer to tm structure to place result
tz Time zone variable. All formats that glibc supports can be given. NULL if current zone is used.
See http://www.gnu.org/software/libtool/manual/libc/TZ-Variable.html
Returns:
result pointer or NULL if error

Referenced by internal_tz_cmp(), and mcc_tz_find_tz_in_country_tz_list().

int internal_setenv_tz ( const char *  tzname  ) 

Set TZ environment variable and re-init time module of glibc to use given timezone. If required it converts timezone from internal clockd fromat to known by glibc.

Parameters:
tzname Time zone variable
Returns:
0 if OK or error code

Referenced by handle_csd_net_time_change(), internal_tz_res(), internal_tz_set(), server_init(), and server_set_tz_cb().

int internal_tz_cmp ( const char *  firstTZName,
const char *  secondTZName 
)

Helper function used to compare TZs

Parameters:
firstTZName First TZ Name
secondTZName Second TZ Name
Returns:
0 if TZ are equal, not 0 otherwise

Referenced by handle_csd_net_time_change(), and tz_name_compare().

int internal_check_timezone ( const char *  zone  ) 

Checks if timezone name is valid for glibc. See http://www.gnu.org/software/libtool/manual/libc/TZ-Variable.html

Parameters:
zone Tested timezone name
Returns:
0 if valid or -1 if invalid

Referenced by server_set_tz_cb().


Generated on Mon Jun 21 15:45:53 2010 for clockd by  doxygen 1.5.6