public static string toLocale(bool self) { return(Env.cur().locale(Sys.m_sysPod, self ? "boolTrue" : "boolFalse", toStr(self))); }
static TimeZone() { try { loadIndex(); } catch (Exception e) { System.Console.WriteLine("ERROR: Cannot load timezone database"); Err.dumpStack(e); } try { m_utc = fromStr("Etc/UTC"); } catch (Exception e) { System.Console.WriteLine("ERROR: Cannot init UTC timezone"); Err.dumpStack(e); m_utc = loadFallback("Etc/UTC", "UTC"); } try { m_rel = fromStr("Etc/Rel"); } catch (Exception e) { System.Console.WriteLine("ERROR: Cannot init Rel timezone"); Err.dumpStack(e); m_rel = loadFallback("Etc/Rel", "Rel"); } try { // first check system property string sysProp = (string)Env.cur().vars().get("fan.timezone"); if (sysProp != null) { m_cur = fromStr(sysProp); } // we assume Java default uses Olson name else { // TODO - no clue how to auto map this yet //cur = fromStr(java.util.TimeZone.getDefault().getID()); m_cur = fromStr("America/New_York"); } } catch (Exception e) { System.Console.WriteLine("ERROR: Cannot init current timezone"); Err.dumpStack(e); m_cur = m_utc; } }
////////////////////////////////////////////////////////////////////////// // Locale ////////////////////////////////////////////////////////////////////////// public string toLocale() { long ticks = this.m_ticks; Pod pod = Sys.m_sysPod; Env env = Env.cur(); Locale locale = Locale.cur(); StringBuilder s; // less than 1000ns Xns if (ticks < 1000L) { return(ticks + env.locale(pod, "nsAbbr", "ns", locale)); } // less than 2ms X.XXXms if (ticks < 2 * nsPerMilli) { s = new StringBuilder(); long ms = ticks / nsPerMilli; long us = (ticks - ms * nsPerMilli) / 1000L; s.Append(ms); s.Append('.'); if (us < 100) { s.Append('0'); } if (us < 10) { s.Append('0'); } s.Append(us); if (s[s.Length - 1] == '0') { s.Length = s.Length - 1; } if (s[s.Length - 1] == '0') { s.Length = s.Length - 1; } s.Append(env.locale(pod, "msAbbr", "ms", locale)); return(s.ToString()); } // less than 2sec Xms if (ticks < 2L * nsPerSec) { return((ticks / nsPerMilli) + env.locale(pod, "msAbbr", "ms", locale)); } // less than 2min Xsec if (ticks < 1L * nsPerMin) { return((ticks / nsPerSec) + env.locale(pod, "secAbbr", "sec", locale)); } // [Xdays] [Xhr] Xmin Xsec long days = ticks / nsPerDay; ticks -= days * nsPerDay; long hr = ticks / nsPerHr; ticks -= hr * nsPerHr; long min = ticks / nsPerMin; ticks -= min * nsPerMin; long sec = ticks / nsPerSec; s = new StringBuilder(); if (days > 0) { s.Append(days).Append(days == 1 ? env.locale(pod, "dayAbbr", "day", locale) : env.locale(pod, "daysAbbr", "days", locale)).Append(" "); } if (hr > 0) { s.Append(hr).Append(env.locale(pod, "hourAbbr", "hr", locale)).Append(" "); } if (min > 0) { s.Append(min).Append(env.locale(pod, "minAbbr", "min", locale)).Append(" "); } if (sec > 0) { s.Append(sec).Append(env.locale(pod, "secAbbr", "sec", locale)).Append(" "); } s.Length = s.Length - 1; return(s.ToString()); }
////////////////////////////////////////////////////////////////////////// // Init Env ////////////////////////////////////////////////////////////////////////// private static bool initEnv() { try { string var = (string)Env.cur().vars().get("FAN_ENV"); if (var == null) return true; m_curEnv = (Env)Type.find(var).make(); } catch (Exception e) { initWarn("curEnv", e); } return true; }
////////////////////////////////////////////////////////////////////////// // Identity ////////////////////////////////////////////////////////////////////////// public static long hash(Service self) { return(Env.cur().idHash(self)); }
public static void make_(Env self, Env parent) { self.m_parent = parent; }
public static void make_(Env self) { make_(self, cur()); }
public Env(Env parent) : this() { this.m_parent = parent; }
public EnvProps(Env env) { this.m_env = env; }
////////////////////////////////////////////////////////////////////////// // Constructor ////////////////////////////////////////////////////////////////////////// public EnvIndex(Env env) { this.m_env = env; }