1
  
2
  
3
  
4
  
5
  
6
  
7
  
8
  
9
  
10
  
11
  
12
  
13
  
14
  
15
  
16
  
17
  
18
  
19
  
20
  
21
  
22
  
23
  
24
  
25
  
26
  
27
  
28
  
29
  
30
  
31
  
32
  
33
  
34
  
35
  
36
  
37
  
38
  
39
  
40
  
41
  
42
  
43
  
44
  
45
  
46
  
47
  
48
  
49
  
50
  
51
  
52
  
53
  
54
  
55
  
56
  
57
  
58
  
59
  
60
  
61
  
62
  
63
  
64
  
65
  
66
  
67
  
68
  
69
  
70
  
71
  
72
  
73
  
74
  
75
  
76
  
77
  
78
  
static private int stage=0; 
static private int booted=0; 
static private object defcal; 
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" >); 
 
#include "localization.h" 
 
#if 1 
mixed `[](string what) 
{ 
//     werror("%O\n",what); 
   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! 
   } 
   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; 
   } 
   if (!defcal) 
   { 
      if (!iso_utc) `[]("ISO_UTC"); 
      stage++; 
      defcal=master()->resolv("Calendar")[default_calendar]; 
      stage--; 
   } 
   return defcal[what]; 
} 
mixed `-> = `[]; 
#endif