Пример #1
0
        /// <summary>
        /// Gets the current time zone for PHP date-time library functions. Associated with the current context.
        /// </summary>
        /// <remarks>It returns the time zone set by date_default_timezone_set PHP function.
        /// If no time zone was set, the time zone is determined in following order:
        /// 1. the time zone set in configuration
        /// 2. the time zone of the current system
        /// 3. default UTC time zone</remarks>
        internal static TimeZoneInfo GetCurrentTimeZone(Context ctx)
        {
            var info = ctx.TryGetProperty <TimeZoneInfo>();

            // if timezone is set by date_default_timezone_set(), return it

            if (info == null)
            {
                // default timezone was not set, use & cache the current timezone
                var cache = ctx.TryGetProperty <CurrentTimeZoneCache>();
                if (cache == null)
                {
                    ctx.SetProperty(cache = new CurrentTimeZoneCache());
                }

                info = cache.TimeZone;
            }

            //
            return(info);
        }
Пример #2
0
 /// <summary>
 /// Clears thread static field. Called on request end.
 /// </summary>
 private static void Clear()
 {
     _current = null;
     _default = null;
 }