示例#1
0
        public Instant ParseTimeDate(string timeDate, bool withoutDaylightSaving = false, MxCultureInfo.FormatType formatType = MxCultureInfo.FormatType.DateTime, bool longFormat = false, string cultureTab = null)
        {
            var rc = ExtNodatime.InstantError;

            var cookies = new MxCookies(HttpContextAccessor);

            if (SupportedCultures.IsSupported(cultureTab) == false)
            {
                cultureTab = SupportedCultures.GetCultureTab(cookies.GetValue(MxSupportedCultures.CookieName));
            }

            if (timeDate.ParseDateTime(DateTimeZoneProviders.Tzdb[SupportedTimeZones.GetTzDbName(cultureTab)], cultureTab, withoutDaylightSaving, formatType, longFormat, out var result))
            {
                rc = result;
            }

            return(rc);
        }
示例#2
0
        public string InstantToString(Instant timeInstant, string cultureTab = null, bool withoutDaylightSaving = false, MxCultureInfo.FormatType formatType = MxCultureInfo.FormatType.DateTime, bool longFormat = false)
        {
            var rc = "[error]";

            try
            {
                var cookies = new MxCookies(HttpContextAccessor);
                if (SupportedCultures.IsSupported(cultureTab) == false)
                {
                    cultureTab = SupportedCultures.GetCultureTab(cookies.GetValue(MxSupportedCultures.CookieName));
                }

                rc = timeInstant.ToString(cultureTab, DateTimeZoneProviders.Tzdb[SupportedTimeZones.GetTzDbName(cultureTab)]);
            }
            catch (Exception)
            {
                //ignore
            }
            return(rc);
        }
示例#3
0
        public string GetCultureTab()
        {
            var cookies = new MxCookies(HttpContextAccessor);

            return(SupportedCultures.GetCultureTab(cookies.GetValue(MxSupportedCultures.CookieName)));
        }