public static string BeautifyPeriod(this DateTime fromDate, DateTime toDate, bool withYear = true)
        {
            var cultureInfo = CultureInfo.CurrentCulture;
            var textInfo = cultureInfo.TextInfo;
            var dateTimeFormat = cultureInfo.DateTimeFormat;

            if (fromDate.Date == toDate.Date)
                return withYear ? fromDate.ToLongDateString() : fromDate.ToShortDateString();
            else if (fromDate.FirstDateOfMonth() == fromDate && toDate.LastDateOfMonth() == toDate)
            {
                if (fromDate.Year == toDate.Year)
                {
                    var fromMonthName = textInfo.ToTitleCase(dateTimeFormat.GetMonthName(fromDate.Month));
                    var toMonthName = textInfo.ToTitleCase(dateTimeFormat.GetMonthName(toDate.Month));

                    if (fromDate.Month == toDate.Month)
                        return withYear ? fromMonthName + " " + fromDate.Year.ToString() : fromMonthName;
                    else
                        return withYear ? fromMonthName + " - " + toMonthName + " " + fromDate.Year.ToString()
                            : fromMonthName + " - " + toMonthName;
                }
                else
                {
                    return textInfo.ToTitleCase(fromDate.ToString(dateTimeFormat.YearMonthPattern))
                            + " - " +
                            textInfo.ToTitleCase(toDate.ToString(dateTimeFormat.YearMonthPattern));
                }
            }

            return fromDate.ToShortDateString() + " - " + toDate.ToShortDateString();
        }
        public void LastDateOfMonth()
        {
            var d1 = new DateTime(2013, 1, 25);
            var d2 = new DateTime(2012, 2, 28);
            var d3 = new DateTime(2013, 4, 15);

            var eD1 = new DateTime(2013, 1, 31);
            var eD2 = new DateTime(2012, 2, 29);
            var eD3 = new DateTime(2013, 4, 30);

            Assert.AreEqual(eD1, d1.LastDateOfMonth());
            Assert.AreEqual(eD2, d2.LastDateOfMonth());
            Assert.AreEqual(eD3, d3.LastDateOfMonth());
        }