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

version» Context lines:

pike.git/lib/modules/Calendar.pmod/YMD.pike:2807:      protected mapping abbr2zones;      // dwim timezone and call dwim time of day above   // this API may change without further notice   protected TimeRange dwim_zone(TimeRange origin,string zonename,    string whut,int ...args)   {    if (zonename=="") return 0;    +  Calendar.Rule.Timezone zone = Calendar.Timezone[zonename]; +  +  if( !zone ) +  {    if (zonename[0]=='"') sscanf(zonename,"\"%s\"",zonename);    sscanf(zonename,"%*[ \t]%s",zonename);       if(sizeof(zonename)==4 && zonename[2]=='S')    zonename = zonename[0..1] + zonename[3..3];    else if(sizeof(zonename)>4 && has_suffix(zonename, "DST"))    zonename = zonename[..<3];       if (origin->rules->abbr2zone[zonename])    zonename=origin->rules->abbr2zone[zonename];    -  Calendar.Rule.Timezone zone=Calendar.Timezone[zonename]; +  zone=Calendar.Timezone[zonename]; +     if (!zone)    {    if (sscanf(zonename,"%[^+-]%s",string a,string b)==2 && a!="" && b!="")    {    TimeRange tr=dwim_zone(origin,a,whut,@args);    if (!tr) return 0;       return    dwim_tod(origin->set_timezone(    Calendar.Timezone.make_new_timezone(
pike.git/lib/modules/Calendar.pmod/YMD.pike:2844:    abbr2zones = master()->resolv("Calendar")["TZnames"]["abbr2zones"];    array pz=abbr2zones[zonename];    if (!pz) return 0;    foreach (pz,string zn)    {    TimeRange try=dwim_zone(origin,zn,whut,@args);    if (try && try->tzname()==zonename) return try;    }    return 0;    } -  else +  }    return dwim_tod(origin->set_timezone(zone),whut,@args);   }      protected mapping(string:array) parse_format_cache=([]);      protected mapping dwim_year=([ "past_lower":70, "past_upper":100,    "current_century":2000, "past_century":1900 ]);      TimeRange parse(string fmt,string arg,void|TimeRange context)   {
pike.git/lib/modules/Calendar.pmod/YMD.pike:3046:    case "am":    if (h==12) h=0;    break;    case "pm":    if (h!=12) h+=12;    break;    default:    return 0; // need "am" or "pm"    }    } -  +     if (m->z) // zone    low = dwim_zone(low,m->z,g,h,mi,s);    else if (g)    low = dwim_tod(low,g,h,mi,s);    else if (!zero_type(m->S))    low = Second(m->S);    if (sub_second)    low = low->fraction(sub_second);    return low;   
pike.git/lib/modules/Calendar.pmod/YMD.pike:3267:    }       error("Failed to dwim time from %O\n",what);   }      // Parses time according to HTTP 1.1 (RFC 2616) HTTP-date token.   TimeofDay http_time(string what, void|TimeRange cx)   {    TimeofDay t;    -  string date1 = "%D %M %Y"; // 2+1+3+1+4=11 -  string date2 = "%D-%M-%y"; // 2+1+3+1+2=9 -  string date3 = "%M %*[ ]%D"; // 2+1+2=5 -  string time = "%h:%m:%s"; // 2+1+2+1+2=8 +  constant date1 = "%D %M %Y"; // 2+1+3+1+4=11 +  constant date2 = "%D-%M-%y"; // 2+1+3+1+2=9 +  constant date3 = "%M %*[ ]%D"; // 2+1+2=5 +  constant time = "%h:%m:%s"; // 2+1+2+1+2=8       // 3+2+ 11 +1+ 8 +4 = 29 -  string rfc1123_date = "%e, "+date1+" "+time+" %z"; +  constant rfc1123_date = "%e, "+date1+" "+time+" %z";       // 6+2+ 9 +1+ 8 +4 = 33 -  string rfc850_date = "%e, "+date2+" "+time+" %z"; +  constant rfc850_date = "%e, "+date2+" "+time+" %z";       // 3+1+ 5 +1+ 8 +1+4 = 23 -  string asctime_date = "%e "+date3+" "+time+" %Y"; +  constant asctime_date = "%e "+date3+" "+time+" %Y";       if( sizeof(what)<23 ) return 0;       if( (t=parse(rfc1123_date, what, cx)) ||    (t=parse(rfc850_date, what, cx)) ||    (t=parse(asctime_date+" %z", what+" GMT", cx)) )    return t;       return 0;   }