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

version» Context lines:

pike.git/lib/modules/Calendar.pmod/YMD.pmod:2404:   {    string nfmt;       nfmt=replace(fmt," %","%*[ \t]%"); // whitespace -> whitespace   #define ALNU "%[^- -,./:-?[-`{-¿]"   #define AMPM "%[ampAMP]"   #define NUME "%[0-9]"    nfmt=replace(nfmt,    ({"%Y","%y","%M","%W","%D","%a","%e","%h","%m","%s","%p",    "%t","%f","%d","%z","%n"}), -  ({ALNU,ALNU,ALNU,"%d","%d","%d",ALNU,"%d","%d","%d",AMPM, +  ({ALNU,ALNU,ALNU,"%d",NUME,"%d",ALNU,"%d","%d","%d",AMPM,    NUME,NUME,NUME,"%[-+0-9A-Za-z/]","%s"}));    array q=Array.map(replace(fmt,({"%*","%%"}),({"",""}))/"%",    lambda(string s){ return s[..0];})-({""});    array res=array_sscanf(arg,nfmt);       if (sizeof(res)<sizeof(q))    return 0; // parse error       mapping m=mkmapping(q,res);   
pike.git/lib/modules/Calendar.pmod/YMD.pmod:2432:   #else    werror("%O\n",m);   #endif    if (m->n && m->n!="") return 0;       string x;    if (m->Y)    m->Y=default_rules->language[f_year_number_from_name](m->Y);       if (!zero_type(m->Y) && m->D && (int)m->M) -  low=m->day=cal->Day(m->Y,(int)m->M,m->D); +  low=m->day=cal->Day(m->Y,(int)m->M,(int)m->D);       if (m->d)    {    int y,mo,d;       if (strlen(m->d)==6)    {    [y,mo,d]=(array(int))(m->d/2);    if (y<70) y+=2000; else y+=1900;    }
pike.git/lib/modules/Calendar.pmod/YMD.pmod:2472:    else low=m->year=cal->Year();       if (m->M)    {    m->month=low=m->year->month(m->M);    }    if (m->W)    m->week=low=m->year->week("w"+m->W);       if (!zero_type(m->D)) -  if (stringp(m->D)) return 0; -  else m->day=low=(m->month||cal->Month())->day(m->D); +  m->day=low=(m->month||cal->Month())->day((int)m->D);    else if (!zero_type(m->a))    m->day=low=m->year->day(m->a);    else if (!zero_type(m->e))    m->day=low=(m->week||cal->Week())->day(m->e);    else    low=m->day=cal->Day();       if (m->day && zero_type(m->Y) && zero_type(m->y) && m->e)    if (m->month)    {
pike.git/lib/modules/Calendar.pmod/YMD.pmod:2566:    })   #endif    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   //! "%y-%M-%D (%M) -W%W-%e (%e)" "2000-03-20 (Mar) -W12-1 (Mon)" + //! "%M%/%D/%y" "3/20/2000"   //! "%D%*[ /]%M%*[ /-,]%y" "20/3/2000" "20 mar 2000" "20/3 -00"   //! "%e%*[ ]%D%*[ /]%M%*[ /-,]%y" "Mon 20 Mar 2000" "Mon 20/3 2000"   //! "%y-%M-%D" "2000-03-20", "00-03-20"   //! "%d" "20000320", "000320"   //! "-%y%*[ /]%D%*[ /]%M" "-00 20/3" "-00 20 mar"   //! "-%y%*[ /]%M%*[ /]%D" "-00 3/20" "-00 march 20"   //! "%y%*[ /]%D%*[ /]%M" "00 20 mar" "2000 20/3"   //! "%y%*[ /]%M%*[ /]%D" "2000 march 20"   //! "%D%*[ -/]%M" "20/3" "20 mar" "20-03"   //! "%M%*[ -/]%D" "3/20" "march 20"
pike.git/lib/modules/Calendar.pmod/YMD.pmod:2626:   Calendar.dwim_day("1");   Calendar.dwim_day("today");   Calendar.dwim_day("last monday");   Calendar.dwim_day("next monday");      */      array dwim_day_strings=   ({"%y-%M-%D (%*s) -W%W-%e (%e)",    "%e%*[, ]%M%*[ ,]%D%*[ ,]%y", +  "%y-%M-%D", +  "%M/%D/%y",    "%D%*[ /]%M%*[- /,]%y",    "%M %D%*[- /,]%y",    "%e%*[, ]%D%*[a-z:]%*[ /]%M%*[-/ ,]%y", -  "%y-%M-%D", +     "-%y%*[ /]%D%*[ /]%M",    "-%y%*[ /]%M%*[ /]%D",    "%y%*[ /]%M%*[ /]%D",    "%y%*[ /]%D%*[ /]%M",    "%D%*[- /]%M",    "%M%*[- /]%D", -  +  "%M-%D-%y", +  "%D-%M-%y",    "%e%*[- /wv]%W%*[ -/]%y",    "%e%*[- /wv]%W",    "%d"});      cDay dwim_day(string day)   {    cDay d;       foreach ( dwim_day_strings,    string dayformat) -  if ( (d=parse(dayformat,day)) ) return d; +  if ( (d=parse(dayformat+"%n",day)) ) +  return d;       cDay t=Day();    if ( (d=parse("%e",day)) )    {    if (d>=t) return d;    else return (d->week()+1)->place(d);    }       if (strlen(day)==4) catch { return parse("%M/%D",day/2*"/"); };