Exemple #1
0
        protected override void OnCreate(Bundle bundle)
        {
            // If these are not used the ToString for DateTime throws an exception in some cultures
            // For more information: https://forums.xamarin.com/discussion/42899/datetime-tostring-throws-argumentoutofrangeexception-in-thai-locale
            var c1  = new System.Globalization.ChineseLunisolarCalendar();
            var c2  = new System.Globalization.GregorianCalendar();
            var c3  = new System.Globalization.HebrewCalendar();
            var c4  = new System.Globalization.HijriCalendar();
            var c5  = new System.Globalization.JapaneseCalendar();
            var c6  = new System.Globalization.JapaneseLunisolarCalendar();
            var c7  = new System.Globalization.JulianCalendar();
            var c8  = new System.Globalization.KoreanCalendar();
            var c9  = new System.Globalization.KoreanLunisolarCalendar();
            var c10 = new System.Globalization.PersianCalendar();
            var c11 = new System.Globalization.TaiwanCalendar();
            var c12 = new System.Globalization.TaiwanLunisolarCalendar();
            var c13 = new System.Globalization.ThaiBuddhistCalendar();
            var c14 = new System.Globalization.UmAlQuraCalendar();

            StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
            StrictMode.SetVmPolicy(builder.Build());

            base.OnCreate(bundle);

            CrossCurrentActivity.Current.Init(this, bundle);
            PermissionsHelper.Activity = this;

            this.SetTheme(Resource.Style.Theme_Design_Light);

            //CachedImageRenderer.Init(false);
            FFImageLoading.Forms.Platform.CachedImageRenderer.Init(false);

            global::Xamarin.Forms.Forms.Init(this, bundle);
            LoadApplication(new App());
        }
        //
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            // If these are not used the ToString for DateTime throws an exception in some cultures
            // For more information: https://forums.xamarin.com/discussion/42899/datetime-tostring-throws-argumentoutofrangeexception-in-thai-locale
            var c1  = new System.Globalization.ChineseLunisolarCalendar();
            var c2  = new System.Globalization.GregorianCalendar();
            var c3  = new System.Globalization.HebrewCalendar();
            var c4  = new System.Globalization.HijriCalendar();
            var c5  = new System.Globalization.JapaneseCalendar();
            var c6  = new System.Globalization.JapaneseLunisolarCalendar();
            var c7  = new System.Globalization.JulianCalendar();
            var c8  = new System.Globalization.KoreanCalendar();
            var c9  = new System.Globalization.KoreanLunisolarCalendar();
            var c10 = new System.Globalization.PersianCalendar();
            var c11 = new System.Globalization.TaiwanCalendar();
            var c12 = new System.Globalization.TaiwanLunisolarCalendar();
            var c13 = new System.Globalization.ThaiBuddhistCalendar();
            var c14 = new System.Globalization.UmAlQuraCalendar();

            AnalyticsHelper.Initialize(Xamarin.Forms.Device.iOS);

            global::Xamarin.Forms.Forms.Init();

            CachedImageRenderer.Init();

            LoadApplication(new App());

            UITextField.Appearance.TintColor = Xamarin.Forms.Color.FromHex("#2548D8").ToUIColor();
#if __TESTS__
            Xamarin.Calabash.Start();
#endif
            return(base.FinishedLaunching(app, options));
        }
        public static DateTime ConverGhamariToMiladi(string time)
        {
            System.Globalization.HijriCalendar hijriCalendar = new System.Globalization.HijriCalendar();
            int      year       = Convert.ToInt32(time.Substring(0, 4));
            int      month      = Convert.ToInt32(time.Substring(5, 2));
            int      day        = Convert.ToInt32(time.Substring(8, 2));
            DateTime miladiDate = new DateTime(year, month, day, hijriCalendar);

            return(miladiDate);
        }
        public static Date ConverMiladiToGhamari(System.DateTime time)
        {
            System.Globalization.HijriCalendar hijriCalendar = new System.Globalization.HijriCalendar();
            int year  = hijriCalendar.GetYear(time);
            int month = hijriCalendar.GetMonth(time);
            int day   = hijriCalendar.GetDayOfMonth(time);
            //string hijriDate = $"{date.Year}/{date.Month.ToString().PadLeft(2, '0')}/{date.Day.ToString().PadLeft(2, '0')}";
            Date hijriDate = new Date(year: year, month: month, day: day);

            return(hijriDate);
        }
Exemple #5
0
        public static System.DateTime GetIslamicNewYear(System.DateTime utcYear)
        {
            System.Globalization.HijriCalendar     arab      = new System.Globalization.HijriCalendar();
            System.Globalization.GregorianCalendar gregorian = new System.Globalization.GregorianCalendar();

            System.DateTime islamicNewYear = arab.ToDateTime(utcYear.Year - CorrelatingDelta(utcYear.Year), 1, 1, 0, 0, 0, 0);

            int year  = gregorian.GetYear(islamicNewYear);
            int month = gregorian.GetMonth(islamicNewYear);
            int day   = gregorian.GetDayOfMonth(islamicNewYear);

            return(new System.DateTime(year, month, day));
        }
Exemple #6
0
        public static string ArCalendar(DateTime dt)
        {
            DateTime miladi = dt;

            string ardate;

            System.Globalization.HijriCalendar shamsi = new System.Globalization.HijriCalendar();
            ardate = string.Format(string.Format("{2}/{1}/{0}", shamsi.GetYear(miladi), shamsi.GetMonth(miladi), shamsi.GetDayOfMonth(miladi)), "dd/MM/yyyy");

            return(ardate);

            //   get { return ardate; }
            //set { _ArCalendar = value; }
        }
        private static LunarDate ConvertToIslamic(DateTime?date, int year, int month, int day, bool isDateTime)
        {
            var   lunarDate = new LunarDate();
            float jd;

            if (isDateTime)
            {
                if (date.HasValue)
                {
                    jd = gregorian_to_jd(date.Value.Year, date.Value.Month, date.Value.Day);
                }
                else
                {
                    throw new NullReferenceException();
                }
            }
            else // Persian
            {
                jd   = persian_to_jd(year, month, day);
                date = ConvertToGregorian(year, month, day, DateType.Persian);
            }

            var lunar   = jd_to_islamic(jd);
            var weekday = Convert.ToInt32(date.Value.DayOfWeek);

            weekday             = weekday >= 6 ? weekday - 6 : weekday + 1;
            lunarDate.DayOfWeek = weekday;
            lunarDate.ArrayType = isDateTime ? new[] { lunar[0], lunar[1], lunar[2], date.Value.Hour, date.Value.Minute, date.Value.Second } : new[] { lunar[0], lunar[1], lunar[2], 0, 0, 0 };

            var cal = new System.Globalization.HijriCalendar();

            lunarDate.ArrayType[2] = cal.GetDayOfMonth(date.Value.Date);
            lunarDate.ArrayType[1] = cal.GetMonth(date.Value.Date);

            return(lunarDate);
        }
Exemple #8
0
        //===================================================================================================
        /// <summary>
        /// تابع مبدل تقویم میلادی سیستم به هجری
        /// با فراخوانی این تابع تبدیل های لازم انجام گرفته و خصوصیات این کلاس مقدار دهی میشود.
        /// </summary>
        public void ConvertDateToHijri(DateTime dt)
        {
            System.Globalization.HijriCalendar   Hijri = new System.Globalization.HijriCalendar();
            System.Globalization.PersianCalendar p     = new System.Globalization.PersianCalendar();
            DateTime Hi = dt;

            //
            yearPersian  = p.GetYear(dt);
            monthPersian = p.GetMonth(dt);
            dayPersian   = p.GetDayOfMonth(dt);
            //
            yearHijri  = Hijri.GetYear(Hi);
            monthHijri = Hijri.GetMonth(Hi);
            dayHijri   = Hijri.GetDayOfMonth(Hi);

            //StrMonthHijri======================
            if (monthHijri == 1)
            {
                strMonthHijri = "محرم";
            }
            else if (monthHijri == 2)
            {
                strMonthHijri = "صفر";
            }
            else if (monthHijri == 3)
            {
                strMonthHijri = "ربيع الاول";
            }
            else if (monthHijri == 4)
            {
                strMonthHijri = "ربيع الثاني";
            }
            else if (monthHijri == 5)
            {
                strMonthHijri = "جمادي الاولي";
            }
            else if (monthHijri == 6)
            {
                strMonthHijri = "جمادي الثانيه";
            }
            else if (monthHijri == 7)
            {
                strMonthHijri = "رجب";
            }
            else if (monthHijri == 8)
            {
                strMonthHijri = "شعبان";
            }
            else if (monthHijri == 9)
            {
                strMonthHijri = "رمضان";
            }
            else if (monthHijri == 10)
            {
                strMonthHijri = "شوال";
            }
            else if (monthHijri == 11)
            {
                strMonthHijri = "ذي القعده";
            }
            else if (monthHijri == 12)
            {
                strMonthHijri = "ذي الحجه";
            }
            isHoliday = IsHolidayHi();
            SearchStrDayHi();
        }