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

version» Context lines:

pike.git/lib/modules/Calendar.pmod/YMD.pmod:904:    return z;    }          int number_of_hours() { return (number_of_seconds()+3599)/3600; }    cHour hour(void|int n) { return get_unit("hour",n); }    array(cHour) hours(int ...range)    { return get_timeofday("hours",0,3600,Hour,@range); }       int number_of_minutes() { return (number_of_seconds()+59)/60; } -  cMinute minute(void|int n) { return get_unit("minute",n); } +  cMinute minute(void|int n,int ... time) +  { +  if (sizeof(time)) +  return hour(n)->minute(time[0]); +  return get_unit("minute",n); +  }    array(cMinute) minutes(int ...range)    { return get_timeofday("minutes",0,60,Minute,@range); }       int number_of_seconds() { return end()->unix_time()-unix_time(); }    cSecond second(void|int n,int ...time)    {    if (sizeof(time)==2)    return hour(n)->minute(time[0])->second(time[1]);    return get_unit("second",n);    }
pike.git/lib/modules/Calendar.pmod/YMD.pmod:2305:   //! EST America/Panama [UTC-5]   //! GST Asia/Dubai [UTC+4]   //! IST Asia/Jerusalem [UTC+2]   //! WST Australia/Perth [UTC+8]   //! </pre>   //!   //! This mapping is modifiable in the ruleset,   //! see <ref>Ruleset.set_abbr2zone</ref>.       - TimeRange dwim_zone(TimeRange origin,string zonename,int ...args) + // this API may change without further notice +  + TimeRange dwim_zone(TimeRange origin,string zonename, +  string whut,int ...args)   {    if (zonename=="") return 0;    if (origin->rules->abbr2zone[zonename])    zonename=origin->rules->abbr2zone[zonename];    Ruleset.Timezone zone=Timezone[zonename];    if (!zone)    {    array pz=TZnames.abbr2zones[zonename];    if (!pz) return 0;    foreach (pz,string zn)    { -  TimeRange try=dwim_zone(origin,zn,@args); +  TimeRange try=dwim_zone(origin,zn,whut,@args);    if (try->tzname()==zonename) return try;    }    return 0;    }    else -  return origin->set_timezone(zone)->second(@args); +  return origin->set_timezone(zone)[whut](@args);   }      TimeRange parse(string fmt,string arg)   {    string nfmt;       nfmt=replace(fmt," %","%*[ \t]%"); // whitespace -> whitespace   #define ALNU "%[^ -,./:-?[-`{-¿]"   #define AMPM "%[ampAMP]"   #define NUME "%[0-9]"
pike.git/lib/modules/Calendar.pmod/YMD.pmod:2442:    d2=(m2+i)->place(m->day);    if (d2 && d2->week()->day(m->e)==d2) break;    d2=(m2-i)->place(m->day);    if (d2 && d2->week()->day(m->e)==d2) break;    }    if (i==20) return 0;    low=m->day=d2;    }    }    -  int h=0,mi=0,s=0,g=0; +  int h=0,mi=0,s=0; +  string g=0;       if (m->t)    {    if (strlen(m->t)==6) -  [h,mi,s]=(array(int))(m->t/2),g=1; +  [h,mi,s]=(array(int))(m->t/2),g="second";    else if (strlen(m->t)==4) -  [h,mi]=(array(int))(m->t/2),g=1; +  [h,mi]=(array(int))(m->t/2),g="minute";    else return 0;    }    else    { -  if (!zero_type(m->h)) h=m->h,g=1; -  if (!zero_type(m->m)) mi=m->m,g=1; -  if (!zero_type(m->s)) s=m->s,g=1; +  if (!zero_type(m->h)) h=m->h,g="hour"; +  if (!zero_type(m->m)) mi=m->m,g="minute"; +  if (!zero_type(m->s)) s=m->s,g="second";    }       if (!zero_type(m->p))    {    switch (lower_case(m->p))    {    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 -  return dwim_zone(low,m->z,h,mi,s); +  return dwim_zone(low,m->z,g,h,mi,s);    else if (g) -  return low->second(h,mi,s); +  return low[g](h,mi,s);    else    return low;    })    return 0;   }      //! function Day dwim_day(string date)   //! Tries a number of different formats on the given date (in order):   //! <pre>   //! <ref>parse</ref> format as in