a580e12000-09-27Fredrik Hübinette (Hubbe) #pike __REAL_VERSION__
a20af62000-09-26Fredrik Hübinette (Hubbe) 
8872292003-03-10Martin Nilsson //! This is the container class for rules.
78fd532000-07-12Mirar (Pontus Hagland) 
8872292003-03-10Martin Nilsson .Rule.Timezone timezone; .Rule.Language language;
78fd532000-07-12Mirar (Pontus Hagland) 
4c83372000-08-04Mirar (Pontus Hagland) mapping(string:string) abbr2zone= ([ "AMT":"America/Manaus", "AST":"America/Curacao", "CDT":"America/Costa_Rica", "CST":"America/El_Salvador", "EST":"America/Panama", "GST":"Asia/Dubai", "IST":"Asia/Jerusalem", "WST":"Australia/Perth",
e7dce62001-01-11Mirar (Pontus Hagland)  // written out names -> standard abbreviation "Pacific Daylight Time":"PDT", "Pacific Standard Time":"PST", "Central Daylight Time":"CDT", "Central Standard Time":"CST", "Eastern Daylight Time":"EDT", "Eastern Standard Time":"EST",
40481e2001-01-12Mirar (Pontus Hagland)  // local languages "MEZ":"CET", "MESZ":"CEST",
4c83372000-08-04Mirar (Pontus Hagland) ]);
5dc75a2003-03-13Martin Nilsson //!
8872292003-03-10Martin Nilsson this_program set_timezone(string|.Rule.Timezone t)
78fd532000-07-12Mirar (Pontus Hagland) {
8872292003-03-10Martin Nilsson  if (stringp(t)) { t=.Timezone[t]; if (!t) error("No timezone %O\n",t);
78fd532000-07-12Mirar (Pontus Hagland)  } if (!t->is_timezone) error("Not a timezone: %O\n",t);
8872292003-03-10Martin Nilsson  this_program r=clone();
78fd532000-07-12Mirar (Pontus Hagland)  r->timezone=t; return r; }
5dc75a2003-03-13Martin Nilsson //!
8872292003-03-10Martin Nilsson this_program set_language(string|.Rule.Language lang)
78fd532000-07-12Mirar (Pontus Hagland) { this_program r=clone(); if (stringp(lang)) { lang=master()->resolv("Calendar")["Language"][lang]; if (!lang) lang=master()->resolv("Calendar")["Language"]["ISO"]; } if (!lang->is_language) error("Not a language: %O\n",lang); r->language=lang; return r; }
5dc75a2003-03-13Martin Nilsson //! Sets the guess-mapping for timezones. Default is the mapping:
4c83372000-08-04Mirar (Pontus Hagland) //!
5dc75a2003-03-13Martin Nilsson //! @xml{<matrix> //! <r><c><b>Abbreviation</b></c><c><b>Interpretation</b></c> //! <c><b>UTC</b></c></r> //! <r><c>AMT</c><c>America/Manaus</c><c>UTC-4</c></r> //! <r><c>AST</c><c>America/Curacao</c><c>UTC-4</c></r> //! <r><c>CDT</c><c>America/Costa_Rica</c><c>UTC-5</c></r> //! <r><c>CST</c><c>America/El Salvador</c><c>UTC-6</c></r> //! <r><c>EST</c><c>America/Panama</c><c>UTC-5</c></r> //! <r><c>GST</c><c>Asia/Dubai</c><c>UTC+4</c></r> //! <r><c>IST</c><c>Asia/Jerusalem</c><c>UTC+2</c></r> //! <r><c>WST</c><c>Australia/Perth</c><c>UTC+8</c></r> //! </matrix>@}
4c83372000-08-04Mirar (Pontus Hagland) //!
5dc75a2003-03-13Martin Nilsson //! @seealso //! @[YMD.parse] this_program set_abbr2zone(mapping(string:string) abbr2zone)
4c83372000-08-04Mirar (Pontus Hagland) { this_program r=clone();
5dc75a2003-03-13Martin Nilsson  r->abbr2zone=abbr2zone;
4c83372000-08-04Mirar (Pontus Hagland)  return r; }
5dc75a2003-03-13Martin Nilsson //!
8872292003-03-10Martin Nilsson this_program set_rule(.Rule.Language|.Rule.Timezone rule)
78fd532000-07-12Mirar (Pontus Hagland) { this_program r=clone(); if (rule->is_timezone) r->timezone=rule; if (rule->is_language) r->language=rule; return r; }
5dc75a2003-03-13Martin Nilsson //!
78fd532000-07-12Mirar (Pontus Hagland) this_program clone() {
8872292003-03-10Martin Nilsson  this_program r=this_program();
78fd532000-07-12Mirar (Pontus Hagland)  r->timezone=timezone; r->language=language;
8872292003-03-10Martin Nilsson  r->abbr2zone=abbr2zone;
78fd532000-07-12Mirar (Pontus Hagland)  return r; }
5dc75a2003-03-13Martin Nilsson //!
78fd532000-07-12Mirar (Pontus Hagland) int(0..1) `==(this_program other) {
c0dbee2000-08-01Mirar (Pontus Hagland)  if (!objectp(other)) return 0;
78fd532000-07-12Mirar (Pontus Hagland)  return other->timezone==timezone && other->language==language; }