78fd532000-07-12Mirar (Pontus Hagland) static private int stage=0;
55a4d22000-08-01Mirar (Pontus Hagland) static private int booted=0;
78fd532000-07-12Mirar (Pontus Hagland) static private object defcal;
c0dbee2000-08-01Mirar (Pontus Hagland) static private object iso_utc; static private object default_rules; static private multiset magic= // magic + indices(Calendar.ISO) without YMD (< "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", "Second", "Fraction", "now" >);
2cfe5c1998-04-29Mirar (Pontus Hagland) 
78fd532000-07-12Mirar (Pontus Hagland) #include "localization.h"
2cfe5c1998-04-29Mirar (Pontus Hagland) 
78fd532000-07-12Mirar (Pontus Hagland) #if 1 mixed `[](string what)
a2cf041999-05-27Mirar (Pontus Hagland) {
c0dbee2000-08-01Mirar (Pontus Hagland) // werror("%O\n",what);
55a4d22000-08-01Mirar (Pontus Hagland)  if (!booted) { booted++; stage++; // bootstrap in the right order master()->resolv("Calendar")["Ruleset"]; master()->resolv("Calendar")["Timezone"]; master()->resolv("Calendar")["Language"]; master()->resolv("Calendar")["TimeRanges"]; master()->resolv("Calendar")["Calendar"]; master()->resolv("Calendar")["Time"]; master()->resolv("Calendar")["YMD"]; master()->resolv("Calendar")["Gregorian"]; // load ISO iso_utc=master()->resolv("Calendar")["ISO"]->set_timezone("UTC"); 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! }
c0dbee2000-08-01Mirar (Pontus Hagland)  if ( !magic[what] || (stage && what!="default_rules")) return ([])[0]; switch (what) { case "ISO_UTC": 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); } // load ISO_UTC and set timezone if (!iso_utc) `[]("ISO_UTC"); 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) }
78fd532000-07-12Mirar (Pontus Hagland) mixed `-> = `[]; #endif