0068611b4d
Now we manage a timezone and daylight-savings aware version of localtime. We parse UNIX timezone strings. The default (active after the first call to localtime or localtime_r) is CET/CEST, the timezone of Europe/Vienna. The wallclock-time osd-example demonstrates how to set a different timezone via the timezone resource. Note: After startup no timezone is set. So in this state querying the timezone resource will return an empty string. After first call to localtime (if not timezone has been set via the timezone resource) a query to timezone will return the default timezone string for CET/CEST. The string returned by the localtime and utc timezones now also includes the timezone name. New fields tm_gmtoff and tm_zone were added to the tm structure. These are available in BSD systems and when setting special compiler definitions on Linux. Note: the timezone offset information in the tm structure (tm_gmtoff) as well as in the tz structure returned by gettimeofday (tz_minuteswest) may be wrong sign, this code is largely untested.
57 lines
1.3 KiB
C
57 lines
1.3 KiB
C
/*
|
|
* Timezone parsing
|
|
*/
|
|
|
|
/**
|
|
* \file
|
|
* Definitions for timezone parsing
|
|
*
|
|
* \author
|
|
* Ralf Schlatterbeck <rsc@tux.runtux.com>
|
|
*/
|
|
|
|
#ifndef tzparse_h
|
|
#define tzparse_h
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/*
|
|
* Rule for DST switching
|
|
*/
|
|
struct tzrule {
|
|
int r_type; /* type of rule--see below */
|
|
int r_day; /* day number of rule */
|
|
int r_week; /* week number of rule */
|
|
int r_mon; /* month number of rule */
|
|
long r_time; /* transition time of rule */
|
|
};
|
|
|
|
#define JULIAN_DAY 0 /* Jn - Julian day */
|
|
#define DAY_OF_YEAR 1 /* n - day of year */
|
|
#define MONTH_NTH_DAY_OF_WEEK 2 /* Mm.n.d - month, week, day of week */
|
|
|
|
/*
|
|
* Info about timezone offset handling.
|
|
* We get at least a dstname and stdoffset, if no daylight saving is in
|
|
* effect, dstname is NULL and no rule is filled in.
|
|
*/
|
|
struct tzoffset_info {
|
|
const char *stdname;
|
|
const char *dstname;
|
|
long stdoffset;
|
|
long dstoffset;
|
|
struct tzrule start;
|
|
struct tzrule end;
|
|
char namebuf [TZ_MAX_CHARS];
|
|
};
|
|
|
|
int tzparse (const char *name, struct tzoffset_info *tzo);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif // tzparse_h
|