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

version» Context lines:

pike.git/lib/modules/Calendar.pmod/YMD.pmod:2343:    }    else    return origin->set_timezone(zone)[whut](@args);   }      TimeRange parse(string fmt,string arg)   {    string nfmt;       nfmt=replace(fmt," %","%*[ \t]%"); // whitespace -> whitespace - #define ALNU "%[^ -,./:-?[-`{-¿]" + #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",}),    ({ALNU,ALNU,ALNU,"%d","%d","%d",ALNU,"%d","%d","%d",AMPM,    NUME,NUME,NUME,"%[-+0-9A-Za-z/]"}));    array q=Array.map(replace(fmt,({"%*","%%"}),({"",""}))/"%",    lambda(string s){ return s[..0];})-({""});    array res=array_sscanf(arg,nfmt);
pike.git/lib/modules/Calendar.pmod/YMD.pmod:2575:      array dwim_day_strings=   ({"%y-%M-%D (%*s) -W%W-%e (%e)",    "%e%*[, ]%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%*[ /]%D%*[ /]%M", +     "%y%*[ /]%M%*[ /]%D", -  +  "%y%*[ /]%D%*[ /]%M",    "%D%*[- /]%M",    "%M%*[- /]%D",    "%e%*[- /wv]%W%*[ -/]%y",    "%e%*[- /wv]%W",    "%d"});      cDay dwim_day(string day)   {    cDay d;   
pike.git/lib/modules/Calendar.pmod/YMD.pmod:2622:    }       error("Failed to dwim day from %O\n",day);   }      TimeofDay dwim_time(string what)   {    string a,h,m,s;    TimeofDay t;    -  foreach ( ({ " %z","%z",""}), -  string zone ) -  foreach ( ({ "%t", +  foreach ( dwim_day_strings + +  ({""}), +  string dayformat ) +  foreach ( ({ "%t %z", +  "T%t %z",    "T%t", -  +  "%h:%*[ :]%m%*[ :]%s %p %z",    "%h:%*[ :]%m%*[ :]%s %p", -  +  "%h:%*[ :]%m%*[ :]%s %z", +  "%h:%*[ :]%m%*[ :]%s%z",    "%h:%*[ :]%m%*[ :]%s", -  +  "%h:%*[ :]%m %p %z",    "%h:%*[ :]%m %p", -  +  "%h:%*[ :]%m %z", +  "%h:%*[ :]%m%z",    "%h:%*[ :]%m",    "%h%*[ ]%p", -  +  "%[a-zA-Z.] %h:%*[ :]%m%*[ :]%s %p %z",    "%[a-zA-Z.] %h:%*[ :]%m%*[ :]%s %p", -  +  "%[a-zA-Z.] %h:%*[ :]%m%*[ :]%s %z", +  "%[a-zA-Z.] %h:%*[ :]%m%*[ :]%s%z",    "%[a-zA-Z.] %h:%*[ :]%m%*[ :]%s", -  +  "%[a-zA-Z.] %h:%*[ :]%m %p %z",    "%[a-zA-Z.] %h:%*[ :]%m %p", -  +  "%[a-zA-Z.] %h:%*[ :]%m %z", +  "%[a-zA-Z.] %h:%*[ :]%m%z",    "%[a-zA-Z.] %h:%*[ :]%m",    "%[a-zA-Z.] %h%*[ ]%p", }),    string todformat ) -  foreach ( dwim_day_strings + -  ({""}), -  string dayformat ) +     { -  if ( (t=parse(dayformat+"%*[ ,]"+todformat+zone,what)) ) return t; -  if ( (t=parse(todformat+zone+"%*[ ,]"+dayformat,what)) ) return t; + // werror("try: %O\n %O\n", + // dayformat+"%*[ ,]"+todformat, + // todformat+"%*[ ,]"+dayformat); +  if ( (t=parse(dayformat+"%*[ ,]"+todformat,what)) ) return t; +  if ( (t=parse(todformat+"%*[ ,]"+dayformat,what)) ) return t;    }       error("Failed to dwim time from %O\n",what);   }      //-- auxillary functions------------------------------------------------      //!   //! function datetime(int|void unix_time)   //! Replacement for localtime; gives back a mapping: