Branch: Tag:

2006-01-06

2006-01-06 16:12:29 by Martin Bähr <mbaehr@email.archlab.tuwien.ac.at>

make constants to figure out %y modifiable by subclasses without requiring to
rewrite parse() so that other calendars can get something meaningful for %y

Rev: lib/modules/Calendar.pmod/Badi.pmod:1.2
Rev: lib/modules/Calendar.pmod/FAQ:1.9
Rev: lib/modules/Calendar.pmod/YMD.pike:1.12

2585:      static mapping(string:array) parse_format_cache=([]);    + static mapping dwim_year=([ "past_lower":70, "past_upper":100, +  "current_century":2000, "past_century":1900 ]); +    TimeRange parse(string fmt,string arg,void|TimeRange context)   {    [string nfmt,array q]=(parse_format_cache[fmt]||({0,0}));
2663:    if (sizeof(m->d)==6)    {    [y,mo,d]=(array(int))(m->d/2); -  if (y<70) y+=2000; else y+=1900; +  if (y<dwim_year->past_lower) +  y+=dwim_year->current_century; +  else +  y+=dwim_year->past_century;    }    else if (sizeof(m->d)==8)    [y,mo,d]=(array(int))array_sscanf(m->d,"%4s%2s%2s");
2679:    if (sizeof(m->y)<3)    {    m->y=(int)m->y; -  if (m->y<70) m->y+=2000; -  else if (m->y<100) m->y+=1900; +  // FIXME? these should be adjustable for different calendars. +  if (m->y<dwim_year->past_lower) +  m->y+=dwim_year->current_century; +  else if (m->y<dwim_year->past_upper) +  m->y+=dwim_year->past_century;    }    low=m->year=cal->Year(m->y);    }