Getting first date in week given a year,weeknumber and day number in javascript
<p>Following is the code that calculates the week date,</p>

<pre><code>//Gets the week dayNumber date against the year,week number
var getWeekDate = function (year, weekNumber, dayNumber) {

var date = new Date(year, 0, 10, 0, 0, 0),
    day = new Date(year, 0, 4, 0, 0, 0),
    month = day.getTime() - date.getDay() * 86400000;
return new Date(month + ((weekNumber - 1) * 7 + dayNumber) * 86400000);
};
</code></pre>

<p>The code is working fine if I give the following values,</p>

<p><strong>Input:</strong><br>
year = 2012<br>
weekNumber = 1<br>
dayNumber = 0 //My week starts from monday, so I am giving it 0.</p>

<p><strong>Output:</strong><br>
2nd,Jan 2012 //That's correct.</p>

<p><strong>Input:</strong><br>
year = 2013<br>
weekNumber = 1<br>
dayNumber = 0 //My week starts from monday, so I am giving it 0.</p>

<p><strong>Output:</strong><br>
31st,DEC 2012 //That's in-correct.</p>

<p>The first week of 2013 will start from 7th, Jan 2013 i.e.Monday
but the above code is not calculating it correctly.</p>
