using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace BuddyFinance.Common.Helpers { public static class DateTimeHelpers { public static DateTime GetNextPaymentDate(this DateTime date) { var lastDate = DateTime.DaysInMonth(date.Year, date.Month); var nextMonthEnd = new DateTime(date.Year, date.Month, lastDate); if ((nextMonthEnd - date).TotalDays > 5) return nextMonthEnd; date = date.AddMonths(1); lastDate = DateTime.DaysInMonth(date.Year, date.Month); return new DateTime(date.Year, date.Month, lastDate); } } }