a580e12000-09-27Fredrik Hübinette (Hubbe) #pike __REAL_VERSION__
a20af62000-09-26Fredrik Hübinette (Hubbe) 
9eaf1d2008-06-28Martin Nilsson protected private int stage=0; protected private int booted=0; protected private object defcal; protected private object iso_utc; protected private object default_rules; protected constant magic= // magic + indices(Calendar.ISO) without YMD
4c75eb2000-09-17Mirar (Pontus Hagland) (<
c0dbee2000-08-01Mirar (Pontus Hagland)  "ISO_UTC","II", "default_rules", "_sprintf", "set_timezone", "language", "Day", "Year", "Week", "Month", "Hour", "Minute", "datetime", "format_iso", "format_iso_short", "format_iso_tod", "YMD_Time", "parse", "dwim_day", "dwim_time", "datetime_name", "datetime_short_name", "format_day_iso", "format_day_iso_short", "SuperTimeRange", "calendar_name", "calendar_object", "TimeRange", "nulltimerange", "ruleset", "set_ruleset", "inano", "timezone", "set_language", "default_rules", "TimeofDay",
10f2d02006-01-10Martin Bähr  "Second", "Fraction", "now", "Bahai" >);
2cfe5c1998-04-29Mirar (Pontus Hagland) 
c7bb0d2007-05-29Martin Bähr array _indices() { return (array)magic; }
78fd532000-07-12Mirar (Pontus Hagland) #include "localization.h"
2cfe5c1998-04-29Mirar (Pontus Hagland) 
78fd532000-07-12Mirar (Pontus Hagland) #if 1
9eaf1d2008-06-28Martin Nilsson protected mixed `[](string what)
a2cf041999-05-27Mirar (Pontus Hagland) {
55a4d22000-08-01Mirar (Pontus Hagland)  if (!booted) {
192ceb2003-11-22Henrik Grubbström (Grubba)  if (what == "_module_value") return UNDEFINED;
55a4d22000-08-01Mirar (Pontus Hagland)  booted++; stage++; // load ISO
4c75eb2000-09-17Mirar (Pontus Hagland) // it can crash here if you're loading from compiled modules // that is updated without all of the calendar module is updated iso_utc=master()->resolv("Calendar")["ISO"]; iso_utc=iso_utc->set_timezone("UTC");
b033102008-05-23Martin Stjernholm  object Time = master()->resolv("Calendar")["Time"];
a1240e2004-01-11Martin Nilsson  Time->Day = iso_utc->cDay;
55a4d22000-08-01Mirar (Pontus Hagland)  stage--; object tz= master()->resolv("Calendar")["Timezone"][default_timezone]; if (!tz) error("Failed to make default timezone %O\n",default_timezone); else default_rules->timezone=tz; // destructive! }
f2d7a62002-02-14Martin Nilsson  if ( !magic[what] || (stage && what!="default_rules")) return UNDEFINED;
c0dbee2000-08-01Mirar (Pontus Hagland)  switch (what) {
10f2d02006-01-10Martin Bähr  case "Bahai": return master()->resolv("Calendar")["Badi"];
c0dbee2000-08-01Mirar (Pontus Hagland)  case "ISO_UTC":
4c75eb2000-09-17Mirar (Pontus Hagland)  if (!iso_utc) error("ERROR\n");
c0dbee2000-08-01Mirar (Pontus Hagland)  return iso_utc; case "II": return 1; case "default_rules": if (!default_rules) { default_rules=master()->resolv("Calendar")["Ruleset"](); default_rules=default_rules->set_language(default_language); }
4c75eb2000-09-17Mirar (Pontus Hagland)  // load ISO_UTC and set timezone there // if (!iso_utc) `[]("ISO_UTC"); // timezone will be set on the way out, through boot above
c0dbee2000-08-01Mirar (Pontus Hagland)  return default_rules; }
78fd532000-07-12Mirar (Pontus Hagland)  if (!defcal)
aa588f1999-05-30Mirar (Pontus Hagland)  {
c0dbee2000-08-01Mirar (Pontus Hagland)  if (!iso_utc) `[]("ISO_UTC");
78fd532000-07-12Mirar (Pontus Hagland)  stage++; defcal=master()->resolv("Calendar")[default_calendar];
c0dbee2000-08-01Mirar (Pontus Hagland)  stage--;
aa588f1999-05-30Mirar (Pontus Hagland)  }
78fd532000-07-12Mirar (Pontus Hagland)  return defcal[what];
a2cf041999-05-27Mirar (Pontus Hagland) }
b033102008-05-23Martin Stjernholm 
9eaf1d2008-06-28Martin Nilsson protected mixed `-> (string what)
b033102008-05-23Martin Stjernholm { // This becomes an alias. return `[] (what); }
78fd532000-07-12Mirar (Pontus Hagland) #endif