Refactor a subroutine that divides date range into quarters. The subroutine below, GetDetailsQuarterly, accepts two dates. Then it writes out each quarter that falls within the date range. It also gives the first and last day of the quarter. I really don't like how the beginning and ending dates of each quarter are hardcoded. I don't believe this solution accounts for leap year as well. Could someone point me in the right direction to refactor this? Thanks in advance.

GetDetailQuarterly:

    Public Sub GetDetailsQuarterly(ByVal beginDate As Date, ByVal endDate As Date)

Console.WriteLine("{0}&gt;&gt;&gt; date range is {1} - {2} {3}", Environment.NewLine, beginDate, endDate, Environment.NewLine)

Dim incrementingStartDate As Date = beginDate
Dim fy As New FiscalYear()

While incrementingStartDate &lt;= endDate

    fy.qOneBegin = "1/1/" &amp; incrementingStartDate.Year
    fy.qOneEnd = "3/31/" &amp; incrementingStartDate.Year
    fy.qTwoBegin = "4/1/" &amp; incrementingStartDate.Year
    fy.qTwoEnd = "6/30/" &amp; incrementingStartDate.Year
    fy.qThreeBegin = "7/1/" &amp; incrementingStartDate.Year
    fy.qThreeEnd = "9/30/" &amp; incrementingStartDate.Year
    fy.qFourBegin = "10/1/" &amp; incrementingStartDate.Year
    fy.qFourEnd = "12/31/" &amp; incrementingStartDate.Year

    Select Case incrementingStartDate
        Case fy.qOneBegin To fy.qOneEnd
            fy.CurrentQuarter = 1
        Case fy.qTwoBegin To fy.qTwoEnd
            fy.CurrentQuarter = 2
        Case fy.qThreeBegin To fy.qThreeEnd
            fy.CurrentQuarter = 3
        Case fy.qFourBegin To fy.qFourEnd
            fy.CurrentQuarter = 4
        Case Else
            Console.WriteLine("out of range")
    End Select

    Console.WriteLine("your q{0}", fy.CurrentQuarter)
    fy.getCurrentQuarterRange()

    incrementingStartDate = incrementingStartDate.AddMonths(3)

End While
  End Sub


FiscalYear Class:

    Public Class FiscalYear

Public Property qOneBegin() As Date

Public Property qOneEnd() As Date

Public Property qTwoBegin() As Date

Public Property qTwoEnd() As Date

Public Property qThreeBegin() As Date

Public Property qThreeEnd() As Date

Public Property qFourBegin() As Date

Public Property qFourEnd() As Date

Public Property CurrentQuarter As Integer

Public Sub getCurrentQuarterRange()
    Select Case CurrentQuarter
        Case 1
            Console.WriteLine("s: {0}, e: {1}", qOneBegin, qOneEnd)
        Case 2
            Console.WriteLine("s: {0}, e: {1}", qTwoBegin, qTwoEnd)
        Case 3
            Console.WriteLine("s: {0}, e: {1}", qThreeBegin, qThreeEnd)
        Case 4
            Console.WriteLine("s: {0}, e: {1}", qFourBegin, qFourEnd)
        Case Else
            Console.WriteLine("out of range")
    End Select
End Sub
 End Class
I am a bit lost in terms of what you are actually trying to accomplish, but I can give some pointers.

First, leap years do not particularly impact quarters unless you truly have some unique rules. Under normal behaviors, February 29 will be in the same quarter as February 28, and would solidly fall inside quarter 1 in your given scenario. 

Secondly, a quick way to figure out the quarter of a given date (if your quarter system starts at January 1) is the following formula 

Dim currentQuarter as Integer = currentDateTime.Month \ 3 + 1


Similarly, you can perform operations to arrive at quarter beginning and ending dates.

Dim quarterStart = new DateTime(currentDateTime.Year, 3 * (currentQuarter - 1) + 1, 1)
Dim quarterEnd = quarterStart.AddMonths(3).AddSeconds(-1)


For example, using today as the base, you could test the code 

Dim currentDateTime = DateTime.Now

Dim currentQuarter = currentDateTime.Month \ 3 + 1
Dim quarterStart = new DateTime(currentDateTime.Year, 3 * (currentQuarter - 1) + 1, 1)
Dim quarterEnd = quarterStart.AddMonths(3).AddSeconds(-1)

Console.WriteLine(currentQuarter)
Console.WriteLine(quarterStart)
Console.WriteLine(quarterEnd)


And see these results 

2
4/1/2011 12:00:00 AM
6/30/2011 11:59:59 PM