UNPKG

tastypie

Version:

Tastypie is a webservice API framework for Node.js based on Django's Tastypie Framework. It provides a convenient, yet powerful and highly customizable, abstraction for creating REST-style interfaces

17 lines (13 loc) 502 B
define(['./dayOfTheYear'], function (dayOfTheYear) { /** * Return the week of the year based on given firstDayOfWeek */ function weekOfTheYear(date, firstDayOfWeek){ firstDayOfWeek = firstDayOfWeek == null? 0 : firstDayOfWeek; var doy = dayOfTheYear(date); var dow = (7 + date.getDay() - firstDayOfWeek) % 7; var relativeWeekDay = 6 - firstDayOfWeek - dow; return Math.floor((doy + relativeWeekDay) / 7); } return weekOfTheYear; });