I’m looking for a definitive, standard (i.e. certified as being correct or tested reasonably thoroughly) for calculating the ISO week from a date, in Visual Basic (i.e. to run in a Visual Studio Express 2010 Visual Basic project)
(Unsuccessful) Research so far:
-
I found some routines that were Visual Basic for Applications oriented; reliant on Excel environment, some things not present in Visual Studio Express 2010 Visual Basic:
-
DatePart Visual Basic library function may be useful: http://msdn.microsoft.com/en-us/library/20ee97hz(v=vs.80).aspx – BUT apparently there is a bug:
“BUG: Format or DatePart Functions Can Return Wrong Week Number for Last Monday in Year”:
http://support.microsoft.com/kb/200299 (has this been solved? It’s rather old, 2004 so perhaps?) -
Other routines: http://forums.devx.com/showthread.php?t=130782 But doesn’t state how it is based on the ISO standard
-
Also, a search on Stack Overflow gave me results that weren’t quite what I was looking for: https://stackoverflow.com/search?q=iso+week
Thanks @assylias – an answer in that question is pretty close, if not exactly what I’m looking for: https://stackoverflow.com/a/1226248/227926
Note to use this solution I should add that you need to import the Calendar abstract class defintion:
AND then instantiate an Instance of Calendar, I chose Gregorian Calendar as it is the defacto standard, but there are other (cultural) options:
Then, to quote the solution ( https://stackoverflow.com/a/1226248/227926 ):
I will not mark my question as a duplicate, because their question title “Calculate the start and end date of a week given the week number and year in C# (based on the ISO specification)” is distinctly different from mine and they mention C# (not Visual Basic although they do want Visual Basic as well).
Keeping my question present should help others in their search for the same.
Thanks!