Branch: Tag:

2003-03-10

2003-03-10 01:20:30 by Martin Nilsson <mani@lysator.liu.se>

Moved Timezone and Language to Rule.pmod

Rev: lib/modules/Calendar.pmod/Ruleset.pike:1.12

1: - //! module Calendar - //! class Ruleset - //! This is the container class for rules. -  -  +    #pike __REAL_VERSION__    - #pragma dont_save_parent - // Override if someone set __pragma_save_parent__ globally. Other code - // in the calendar module does Ruleset.Timezone(...) which won't work - // if Timezone gets a parent pointer. /mast + //! This is the container class for rules.    - class Timezone - { -  constant is_timezone=1; + .Rule.Timezone timezone; + .Rule.Language language;    - // seconds to utc, not counting DST -  static int offset_to_utc; -  - // timezone name -  string name; -  -  static void create(int offset,string _name) -  { -  offset_to_utc=offset; -  name=_name; -  } -  -  // seconds to UTC, counting DST -  -  array(int) tz_ux(int unixtime) -  { -  return ({offset_to_utc,name}); -  } -  -  array(int) tz_jd(int julian_day) -  { -  return ({offset_to_utc,name}); -  } -  -  string _sprintf(int t) { return (t=='O')?"Timezone("+name+")":0; } -  -  int raw_utc_offset() { return offset_to_utc; } - }; -  - Timezone timezone; -  - class Language - { -  constant is_language=1; -  -  string month_name_from_number(int n); -  string month_shortname_from_number(int n); -  int month_number_from_name(string name); -  -  string week_day_name_from_number(int n); -  string week_day_shortname_from_number(int n); -  int week_day_number_from_name(string name); -  -  string gregoiran_week_day_name_from_number(int n); -  string gregorian_week_day_shortname_from_number(int n); -  int gregorian_week_day_number_from_name(string name); -  -  string week_name_from_number(int n); -  int week_number_from_name(string s); -  string year_name_from_number(int y); - } -  - Language language; -  +    mapping(string:string) abbr2zone=   ([    "AMT":"America/Manaus",
93:    "MESZ":"CEST",   ]);    - this_program set_timezone(string|Timezone t) + this_program set_timezone(string|.Rule.Timezone t)   { -  this_program r=clone(); -  if (stringp(t)) -  { -  t=master()->resolv("Calendar")["Timezone"][t]; -  if (!t) error("no timezone %O\n",t); +  if (stringp(t)) { +  t=.Timezone[t]; +  if (!t) error("No timezone %O\n",t);    }       if (!t->is_timezone)    error("Not a timezone: %O\n",t); -  +  +  this_program r=clone();    r->timezone=t;    return r;   }    - this_program set_language(string|Language lang) + this_program set_language(string|.Rule.Language lang)   {    this_program r=clone();    if (stringp(lang))
148:    return r;   }    - this_program set_rule(Language|Timezone rule) + this_program set_rule(.Rule.Language|.Rule.Timezone rule)   {    this_program r=clone();    if (rule->is_timezone) r->timezone=rule;
158:      this_program clone()   { -  this_program r=object_program(this_object())(); +  this_program r=this_program();    r->timezone=timezone;    r->language=language; -  +  r->abbr2zone=abbr2zone;    return r;   }