-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
39 lines (36 loc) · 762 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/**
* year-weeks <https://github.com/datetime/year-weeks>
*
* Copyright (c) 2014-2015 Charlike Mike Reagent, contributors.
* Released under the MIT license.
*/
'use strict';
var yearDays = require('year-days');
/**
* Get the number of weeks in year - leap or not
*
* **Example:**
*
* ```js
* var yearWeeks = require('year-weeks');
*
* yearWeeks(2014);
* //=> 52
*
* yearWeeks(2016);
* //=> 52
*
* yearWeeks(new Date(2016, 0));
* //=> 52
*
* yearWeeks('2012-12-17T03:24:00');
* //=> 52
* ```
*
* @name yearWeeks
* @param {Date|Number} `[val]` current year ([year-days][year-days]) as valid Date format string, or year as number
* @return {Number}
*/
module.exports = function yearWeeks(val) {
return (yearDays(val) / 7) | 0;
};