![]() ![]() ![]() first week with 4 days of the new year (this is iso 8601) In outlook 2010 you can set how to calculate the first week of a year in the settings of outlook-calendar-options. I think that there has to be an easier solution. Want to show the control in another form with 6 months in it. And it gets much more difficult to calculate this dynamically, for example if you So we had to draw 12 of these rectangles, calculate their positions (which might not be so easy) and so on. My userform is showing the monthCalendar-control with all 12 month. And when I browse to another month I have to select a day to calculate the week number again. The rectangle is in wrong position (could correct this…). paint-event and draws an rectangle in which you write the week numbers. If week 1 started on wednesday as 01 and sat was 04 then display number. Maybe MonthCalendar should display partial weeks. Year displayed by MonthCalendar will have 53 weeks I figure although I only looked at three in a row and all had 53 weeks in them. There is no year that has 52 weeks in it for MonthCalendar calendar used. Perhaps first full week of January 2016 per ISO 8601 begins with 04 Jan. In dotNet Framework week 1 begins with December 28th in 2015. ![]() So, according to this, week 1 begins with Jannuary 4th. In 2016 the first Thursday is Jannuary 7th. Iso 8601 says the first week is the week containing the first Thursday of a year. Well, you think that it is correct that one single week has two week numbers?ĭo you know about iso 8601? Look at this: WeekNumbers.Location = New Point(Width - 247, 50) Protected Overrides Sub OnSizeChanged(e As System.EventArgs) Protected Overrides Sub OnDateChanged(drevent As ) Loop While FirstWeek.DayOfWeek DayOfWeek.ThursdayĮlseIf FirstWeek.DayOfWeek DayOfWeek.Thursdayĭim WeekNumber As Integer = DatePart(DateInterval.WeekOfYear, FirstWeek,, FirstWeekOfYear.FirstFourDays)Į.Graphics.DrawString(WeekNumber.ToString, Font, Brushes.Black, 2, Y) If FirstWeek.DayOfWeek = DayOfWeek.Sunday OrElse FirstWeek.DayOfWeek > DayOfWeek.Thursday Then If FirstWeek.DayOfWeek = DayOfWeek.Monday Then Private Sub WeekNumbers_Paint(sender As Object, e As ) Handles WeekNumbers.Paintĭim FirstWeek As New Date(SelectionStart.Year, SelectionStart.Month, 1) Private WithEvents WeekNumbers As New Control With ![]() However I haven't verified that it is accurate in all cases and so offer it as an idea only and not as fully tested code. I couldn't find any way to make the MonthCalendar use a different method to calculate the week number so I came up with this control which is a bit of a hack but appears to work ok. MsgBox(d.ToString("dddd dd MMM yyyy") & " is week number: " & _ HaveĪ look at the following code for an example: Dim d As New Date(2018, 12, 30) This appeared to work ok in 2006 but I have just been looking at it again and it appears flawed. The DatePart function provides a way to determine the week number for any date with an overload which claims to do so in accordance with ISO 8601. Your own posts is not considered good forum are quite right - there is a problem.ĭiscussion about this many years ago and it became clear that there are several ways of looking at week number, some of which involve having weeks with less than 7 days. ![]()
0 Comments
Leave a Reply. |