기타 [vb.net] 주차 구하기 월, 년 ~번째주
페이지 정보
본문
Public Function GetWeek(ByVal targetDate As DateTime) As Integer
Dim calculationDate As DateTime = New DateTime(targetDate.Year, targetDate.Month, 1)
Dim calenderCalc As Calendar = CultureInfo.CurrentCulture.Calendar
Dim da As Integer = calenderCalc.GetWeekOfYear(targetDate, CalendarWeekRule.FirstDay, DayOfWeek.Sunday)
Dim db As Integer = calenderCalc.GetWeekOfYear(calculationDate, CalendarWeekRule.FirstDay, DayOfWeek.Sunday)
Dim usWeekNumber As Integer = da - db + 1
Return usWeekNumber
End Function
'// 일년중 몇번째주
Public Shared Function GetWeekOfYear(ByVal targetDate As DateTime) As Integer
Return GetWeekOfYear(targetDate, Nothing)
End Function
Public Shared Function GetWeekOfYear(ByVal targetDate As DateTime, ByVal culture As CultureInfo) As Integer
If culture Is Nothing Then culture = CultureInfo.CurrentCulture
Dim weekRule As CalendarWeekRule = culture.DateTimeFormat.CalendarWeekRule
Dim firstDayOfWeek As DayOfWeek = culture.DateTimeFormat.FirstDayOfWeek
Return culture.Calendar.GetWeekOfYear(targetDate, weekRule, firstDayOfWeek)
End Function
- 이전글[vb.net] JSON Example 23.04.09
- 다음글How to use Text-to-Speech within a Visual Basic .NET application 22.12.04
댓글목록
등록된 댓글이 없습니다.