'If the specified date is the last day of the year, GetWeekOfYear returns the total number of weeks in that year.
Imports System
Imports System.Globalization
Public Class SamplesCalendar
Public Shared Sub Main()
Dim myCI As New CultureInfo("en-US")
Dim myCal As Calendar = myCI.Calendar
Dim myCWR As CalendarWeekRule = myCI.DateTimeFormat.CalendarWeekRule
Dim myFirstDOW As DayOfWeek = myCI.DateTimeFormat.FirstDayOfWeek
' Displays the total number of weeks in the current year.
Dim LastDay = New System.DateTime(DateTime.Now.Year, 12, 31)
Console.WriteLine("There are {0} weeks in the current year ({1}).", myCal.GetWeekOfYear(LastDay, myCWR, myFirstDOW), LastDay.Year)
End Sub
End Class
|