JavaScript function to count the number of days passed since beginning of the year