Reputation: 11389
Given a Year, and a day of that year, how can i get the full date? ex: 60/2014
= March First 2014
and 61/2016
= March First 2016
notes: -year and day can be passed as separate parameters.
-result can be a regular Date instance, i just explicitally showed as text to alert for "leap year"
Upvotes: 2
Views: 53
Reputation: 324620
JavaScript has some pretty neat "magic":
var input = "60/2014";
var parts = input.split("/");
var d = new Date(parts[1],0,parts[0]);
That's right. 60th of January. JavaScript will automatically correct this to the first of March.
Upvotes: 8