Exemple #1
0
        public static DateTime ToDate(DateModel model)
        {
            try
            {
                if (model != null)
                {
                    DateTime date = DateTime.MinValue;
                    if (model.CalendarType == CalendarType.Hijri || IsHijri(model.Date))
                    {
                        var dt = HijriToGreg(model.Date);
                        DateTime.TryParseExact(dt, allFormats, enCul.DateTimeFormat,
                                               DateTimeStyles.AllowWhiteSpaces, out date);
                    }
                    else
                    {
                        DateTime.TryParseExact(model.Date, allFormats, enCul.DateTimeFormat,
                                               DateTimeStyles.AllowWhiteSpaces, out date);
                    }

                    return(date);
                }
                return(DateTime.MinValue);
            }
            catch
            {
                return(DateTime.MinValue);
            }
        }
Exemple #2
0
        }// Compare

        public static int Compare(DateModel source, DateModel destination, bool ignoreTime = true)
        {
            var d1 = ToDate(source);
            var d2 = ToDate(destination);

            if (ignoreTime)
            {
                return(DateTime.Compare(d1.Date, d2.Date));
            }
            return(DateTime.Compare(d1, d2));
        }// Compare