pike.git
/
lib
/
modules
/
Calendar.pmod
/
YMD.pike
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/lib/modules/Calendar.pmod/YMD.pike:2578:
if (try && try->tzname()==zonename) return try; } return 0; } else return dwim_tod(origin->set_timezone(zone),whut,@args); } 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})); if (!nfmt) { // nfmt=replace(fmt," %","%*[ \t]%"); // whitespace -> whitespace #define ALNU "%[^- -,./:-?[-`{-¿]" #define AMPM "%[ampAMP.]" #define NUME "%[0-9]"
pike.git/lib/modules/Calendar.pmod/YMD.pike:2656:
low=m->day=cal->Day(m->Y,(int)m->M,(int)m->D); if (m->d) { int y,mo,d; 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"); else return 0; low=m->day=cal->Day(y,mo,d); } else { if (!zero_type(m->Y)) m->year=cal->Year(m->Y); else if (m->y) { 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); } else low=m->year=context?context->year():cal->Year(); if (m->M) { m->month=low=m->year->month(m->M); } if (m->W)