aboutsummaryrefslogtreecommitdiffstats
path: root/stdtime
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2003-09-18 13:34:06 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2003-09-18 13:34:06 +0000
commitbe443a4ea3305e08b986e53445800479e80b4c76 (patch)
tree3ceeb944ee9366e4dbbfe37ef19039a376acb096 /stdtime
parent85d82586fbd13817d3fbb512e53e938cca53ddf4 (diff)
Grab timezone from system config
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@1526 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'stdtime')
-rwxr-xr-xstdtime/localtime.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/stdtime/localtime.c b/stdtime/localtime.c
index f64cec84d..18a1b597c 100755
--- a/stdtime/localtime.c
+++ b/stdtime/localtime.c
@@ -650,6 +650,9 @@ const int lastditch;
register int load_result;
stdname = name;
+#ifdef DEBUG
+ fprintf(stderr, "tzparse(): loading default rules\n");
+#endif
load_result = tzload(TZDEFRULES, sp);
if (load_result != 0)
sp->leapcnt = 0; /* so, we're off a little */
@@ -858,7 +861,14 @@ ast_tzsetwall P((void))
}
memset(cur_state,0,sizeof(struct state));
if (tzload((char *) NULL, cur_state) != 0)
+#ifdef DEBUG
+ {
+ fprintf(stderr, "ast_tzsetwall: calling gmtload()\n");
+#endif
gmtload(cur_state);
+#ifdef DEBUG
+ }
+#endif
if (last_lclptr)
last_lclptr->next = cur_state;
@@ -920,8 +930,14 @@ ast_tzset P((const char *name))
cur_state->ttis[0].tt_abbrind = 0;
(void) strcpy(cur_state->chars, gmt);
} else if (tzload(name, cur_state) != 0)
- if (name[0] == ':' || tzparse(name, cur_state, FALSE) != 0)
+ if (name[0] == ':') {
(void) gmtload(cur_state);
+ } else if (tzparse(name, cur_state, FALSE) != 0) {
+ /* If not found, load localtime */
+ if (tzload("/etc/localtime", cur_state) != 0)
+ /* Last ditch, get GMT */
+ (void) gmtload(cur_state);
+ }
strncpy(cur_state->name,name,sizeof(cur_state->name));
if (last_lclptr)
last_lclptr->next = cur_state;
@@ -972,6 +988,18 @@ const char * const zone;
}
if (sp == NULL) {
+ ast_tzsetwall();
+ sp = lclptr;
+ /* Find the default zone record */
+ while (sp != NULL) {
+ if (sp->name[0] == '\0')
+ break;
+ sp = sp->next;
+ }
+ }
+
+ /* Last ditch effort, use GMT */
+ if (sp == NULL) {
gmtsub(timep, offset, tmp, zone);
return;
}