# Week of Year in jQueryUI Datepicker

I needed to display week of year in a colum on the jqueryUI datepicker. Luckily it has the feature built in. Unluckily it has a quirk relative to the way we typically display calendars in the US with Sunday as the first day colum. At first I thought it was a bug, but technically it is not, so I guess it is better classified as a gotcha. Anyway, to get the week of year to display as we would expect in the US you need two pieces. First where you instantiate the datepicker:

The important argument there is the calculateWeek: myWeekCalc. Next you need to define the custom week of year calculator, in this case myWeekCalc:

I borrowed this from the jqueyUI source and tweaked it to calculate the week based on the Thursday in the row instead of the first day colum in the row. To me this makes sense given the way the ISO for week of year is determined. It seems to be working perfectly for me. Let me know if you use this and run into issues :)