Beispiel #1
0
 public static DateRange ParseString(string value)
 {
     DateRange dateRange = new DateRange();
     dateRange.Parse(value);
     return dateRange;
 }
Beispiel #2
0
        public static DateRange[] CreateForMonthsInRecentQuarters(int range)
        {
            DateTime today = DateTime.UtcNow.Date;
            int quarterMonth = ((today.Month % 3) == 0 ? today.Month : 3 * ((today.Month / 3) + 1));

            DateTime dateTime = new DateTime(DateTime.Today.Year, quarterMonth, 1);

            List<DateRange> dateRanges = new List<DateRange>();
            for (int i = 0; i < range * 3; i++)
            {
                DateRange dateRange = new DateRange();
                dateRange.Parse(dateTime.ToString("MMMyyyy"));
                dateRanges.Add(dateRange);

                dateTime = dateTime.AddMonths(-1);
            }

            //DateTime dateTime = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1);

            //for (int i = 0; i < months; i++)
            //{
            //    DateRange dateRange = new DateRange();
            //    dateRange.Parse(dateTime.AddMonths(-1).ToString("MMMyyyy"));
            //    dateRanges[i] = dateRange;

            //    dateTime = dateTime.AddMonths(-1);
            //}

            return dateRanges.ToArray();
        }