LitterBox/ReportGenerators/TaxReportGenerator.cs
/// <summary>Gets a DateTime representing the specified day of last month (IE if it's currently December 5th, executing
/// this function with param day=15, it would return November 15th). Use day 31 to get the last day of the last month.</summary>
/// <param name="Day"></param>
/// <returns></returns>
Gets a DateTime representing the specified day of last month . Use day 31 to get the last day of the last month.
Gets a DateTime representing the specified day of last month . Use day 31 to get the last day of the last month .
private static DateTime DayOfLastMonth(int Day) {
            int LastMonth = DateTime.Now.Month - 1;
            int Year = DateTime.Now.Year;
            if (LastMonth == 0) {
                Year--;
                LastMonth = 12;
            }
            return new DateTime(Year, LastMonth, Math.Min(Day, DateTime.DaysInMonth(Year, LastMonth)));
        }
private static DateTime DayOfLastMonth ( int Day ) { int LastMonth = DateTime . Now . Month - 1 ; int Year = DateTime . Now . Year ; if ( LastMonth == 0 ) { Year -- ; LastMonth = 12 ; } return new DateTime ( Year , LastMonth , Math . Min ( Day , DateTime . DaysInMonth ( Year , LastMonth ) ) ) ; }
Gets a DateTime representing the specified day of last month (IE if it's currently December 5th, executing
this function with param day=15, it would return November 15th).
Gets a DateTime representing the specified day of last month ( IE if it ' s currently December 5th executing this function with param day = 15 it would return November 15th ) .
//The one condition this may fail in is if we ask for the last 31st and last month didn't have a 31st. //In this and similar instances (if the previous month does not have this date), let's use the month's maximum length.
None
Day
int
None