コード例 #1
0
ファイル: HijriDate.cs プロジェクト: alirezavafi/persian-plus
 public static bool TryParse(string s, out HijriDate pd)
 {
     try
     {
         pd = HijriDate.Parse(s);
         return(true);
     }
     catch (Exception e)
     {
         pd = null;
         return(false);
     }
 }
コード例 #2
0
        public IEnumerable <EventDay> GetEventsByDateRange(DateRange dateRange)
        {
            var allEvents          = new List <EventDay>();
            var gregorianStartDate = dateRange.StartDate;
            var gregorianEndDate   = dateRange.EndDate;
            var startYear          = gregorianStartDate.Year;

            do
            {
                allEvents.AddRange(GetGregorianEventsByYear(startYear));
                startYear++;
            } while (startYear <= gregorianEndDate.Year);

            var hijriStartDate = new HijriDate(gregorianStartDate);
            var hijriEndDate   = new HijriDate(gregorianEndDate);

            startYear = hijriStartDate.Year;
            do
            {
                allEvents.AddRange(GetHijriEventsByYear(startYear));
                startYear++;
            } while (startYear <= hijriEndDate.Year);

            var persianStartDate = new PersianDateTime(gregorianStartDate);
            var persianEndDate   = new PersianDateTime(gregorianEndDate);

            startYear = persianStartDate.Year;
            do
            {
                allEvents.AddRange(GetPerisanEventsByYear(startYear));
                startYear++;
            } while (startYear <= persianEndDate.Year);

            var dateRangeEvents = allEvents
                                  .Where(x => x.DateTime >= gregorianStartDate && x.DateTime < gregorianEndDate).OrderBy(x => x.DateTime)
                                  .ToList();

            return(dateRangeEvents);
        }