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

version» Context lines:

pike.git/lib/modules/Calendar.pmod/mkrules.pike:3:   // ftp://elsie.nci.nih.gov/pub/   // (timezone mailing list: tz@elsie.nci.nih.gov)   //   // source datafile are usually found somewhere around zic(8),   // if they exist in the system.   //   // Most systems only have compiled files, just like pike,   // and zic(8) is the usual compiler.      // pike mkrules.pike ../data/{africa,antarctica,asia,australasia,backward,etcetera,europe,northamerica,pacificnew,southamerica,systemv} - // $Id: mkrules.pike,v 1.13 2008/06/28 19:59:36 nilsson Exp $ + // $Id: mkrules.pike,v 1.14 2009/05/12 12:03:41 grubba Exp $      #pike __REAL_VERSION__      object cal=Calendar.ISO->set_timezone("UTC");   function Year=cal->Year;   object nleapy=Year(1999);      object tzrules; // needed to make timezones, compiled below      mapping rules=([]);
pike.git/lib/modules/Calendar.pmod/mkrules.pike:764:    mv("TZs.pike","TZs.pike~");    werror("writing TZs.h (%d bytes)...",sizeof(t));    Stdio.File("TZs.h","wtc")->write(t);    werror("\n");       mapping zs=([]);    foreach (azones,Zone z)    if (sscanf(z->id,"%s/%s",string s,string t)==2)    zs[s]=(zs[s]||({}))+({t});    -  t="// ----------------------------------------------------------------\n" -  "// Timezone names\n" -  "//\n" -  "// NOTE: this file is generated by mkrules.pike;\n" -  "// please do not edit manually /Mirar\n" -  "// ----------------------------------------------------------------\n" -  "\n" -  "mapping _module_value=\n" +  // Read and parse the original TZnames.pmod file. +  string orig_names = Stdio.read_bytes("TZnames.pmod"); +  array(string) fragments = orig_names/" zones="; +  if (sizeof(fragments) == 1) fragments = orig_names/" zones ="; +  if (sizeof(fragments) > 2) +  fragments = ({ fragments[0], fragments[1..] * " zones =" }); +  fragments[1] = (fragments[1]/"]);\n\n")[1..]*"]);\n\n"; +  +  t = fragments[0] + " zones =\n"    "([\n"; -  foreach (indices(zs)-({"SystemV","Etc"}),string co) +  +  multiset(string) zone_names = (multiset)indices(zs); +  +  zone_names->SystemV = 0; +  zone_names->Etc = 0; +  +  // Historical ordering... +  foreach (({"America", "Pacific", "Antarctica", "Atlantic", "Indian", +  "Europe", "Africa", "Asia", "Australia" }), string co) {    t+=(replace(    sprintf(" %-13s({%-=63s\n",    sprintf("%O:",co),    map(zs[co],lambda(string s) { return sprintf("%O",s); })    *", "+"}),"),({", ",", "}),",,"/1)); -  t+="]);\n\n"; +  zone_names[co] = 0; +  } +  // Take care of any remaining zones (probably none). +  foreach (sort(indices(zone_names)),string co) +  t+=(replace( +  sprintf(" %-13s({%-=63s\n", +  sprintf("%O:",co), +  map(zs[co],lambda(string s) { return sprintf("%O",s); }) +  *", "+"}),"),({", ",", "}),",,"/1)); +  t += "]);\n\n" + +  fragments[1];    -  mv("TZnames.pike","TZnames.pike~"); +  mv("TZnames.pmod","TZnames.pmod~");    werror("writing TZnames.pmod (%d bytes)...",sizeof(t));    Stdio.File("TZnames.pmod","wtc")->write(t);    werror("\n");       return 0;   }         string TZrules_base=   #"// ----------------------------------------------------------------