pike.git / lib / modules / Calendar.pmod / Timezone.pmod

version» Context lines:

pike.git/lib/modules/Calendar.pmod/Timezone.pmod:79: Inside #if 1
     #if 1    string s;       if ( (s=getenv("TZ")) )    {    tz=`[](s);    if (tz) return tz;    }    +  if(s = Stdio.read_bytes("/etc/localtime")) +  { +  tz=tz_from_tzfile(s); +  if (tz) return tz; +  } +    // Linux RedHat    if (Stdio.is_dir("/etc/sysconfig/.") &&    (s = Stdio.read_bytes("/etc/sysconfig/clock")) )    {    sscanf(s,"%*sZONE=\"%s\"",s);    tz=`[](s);   // werror("=>%O\n",tz);    if (tz) return tz;    }   
pike.git/lib/modules/Calendar.pmod/Timezone.pmod:103: Inside #if 1 and #if constant(tzname)
   tz=::`[](tzn[0]);    if (tz && l->timezone==tz->raw_utc_offset()) return tz;   #endif   #endif       // run an expert system try on the localtime() rules,    // default to localtime()    return expert(localtime());   };    + .Rule.Timezone tz_from_tzfile(string tzfile) + { +  array header = array_sscanf(tzfile, "%4s%16s%4c%4c%4c%4c%4c%4c"); +  array zoneabbr = tzfile[44+header[5]*4+header[5]+header[6]*6..44+header[5]*4+header[5]+header[6]*6+header[7]-1]/"\0"; +  if(!expert_tzn) +  expert_tzn=master()->resolv("Calendar")["TZnames"]; +  +  array validzones = `&(@values(expert_tzn->abbr2zones & mkmultiset(zoneabbr))); +  if(sizeof(validzones) == 1) +  return `[](validzones[0]); + } +  +    // ----------------------------------------------------------------   // expert system to pick out the correct timezone      static .Rule.Timezone timezone_expert_rec(.Rule.Timezone try,    mapping|array|string tree,    object cal)   {    int t=tree->test,uo;    if (t<0)    {