/// <summary>
    /// Returns a new PersianDateTime that adds the specified number of years to the value of this instance.
    /// </summary>
    /// <param name="value">A number of years. The value parameter can be negative or positive.</param>
    /// <returns>An object whose value is the sum of the date and time represented by this instance and the number of years represented by value.</returns>
    public PersianDateTime AddYears(int value)
    {
        var newYear = Year + value;

        var daysInNewMonth = PersianDateTime.GetDaysInMonth(newYear, Month);
        var newDay         = daysInNewMonth < Day ? daysInNewMonth : Day;

        return(new PersianDateTime(Year + value, Month, Day).Add(TimeOfDay));
    }
 public void ShowAllDate()
 {
     Console.WriteLine(DateHelper.GetStartOfDayFa().ToFa("YYYY/MM/d  hh:mm:ss"));
     Console.WriteLine(DateHelper.GetStartOfWeekFa().ToFa("YYYY/MM/d  hh:mm:ss"));
     Console.WriteLine(DateHelper.GetStartOfMonthFa().ToFa("YYYY/MM/d  hh:mm:ss"));
     Console.WriteLine(DateHelper.GetStartOfYearFa().ToFa("YYYY/MM/d  hh:mm:ss"));
     Console.WriteLine(PersianDateTime.GetMonthName(-1));
     Console.WriteLine(PersianDateTime.GetDaysInMonth(PersianDateTime.Now.Year, PersianDateTime.Now.Month));
 }
    /// <summary>
    /// Returns a new PersianDateTime that adds the specified number of months to the value of this instance.
    /// </summary>
    /// <param name="value">A number of months. The months parameter can be negative or positive.</param>
    /// <returns>An object whose value is the sum of the date and time represented by this instance and months.</returns>
    public PersianDateTime AddMonths(int value)
    {
        var months = Month + value;

        var newYear  = Year + (months > 0 ? (months - 1) / 12 : months / 12 - 1);
        var newMonth = months > 0 ? (months - 1) % 12 + 1 : months % 12 + 12;

        var daysInNewMonth = PersianDateTime.GetDaysInMonth(newYear, newMonth);
        var newDay         = daysInNewMonth < Day ? daysInNewMonth : Day;

        return(new PersianDateTime(newYear, newMonth, newDay).Add(TimeOfDay));
    }
 private static List <ChartData> FillEmptyFaDayOfMonth(this List <ChartData> retVal)
 {
     for (int i = 1; i <= PersianDateTime.GetDaysInMonth(PersianDateTime.Now.Year, PersianDateTime.Now.Month); i++)
     {
         if (retVal.All(x => x.Range.Trim() != i.ToString()))
         {
             retVal.Add(new ChartData()
             {
                 Count = 0, Range = i.ToString(), Order = i
             });
         }
         else
         {
             retVal.First(x => x.Range.Trim() == i.ToString()).Order = i;
         }
     }
     return(retVal);
 }