isoWeeksInYear

Determine the number of ISO weeks in a year according to the Gregorian calendar.

Usage

var isoWeeksInYear = require( '@stdlib/time/iso-weeks-in-year' );

isoWeeksInYear( [value] )

Returns the number of ISO weeks in a year according to the Gregorian calendar.

var num = isoWeeksInYear();
// returns <number>

By default, the function returns the number of ISO weeks in the current year (according to local time). To determine the number of ISO weeks for a particular year, provide either a year or a Date object.

var num = isoWeeksInYear( new Date() );
// returns <number>

num = isoWeeksInYear( 2015 );
// returns 53

num = isoWeeksInYear( 2017 );
// returns 52

Examples

var isoWeeksInYear = require( '@stdlib/time/iso-weeks-in-year' );

var v;
var i;

for ( i = 0; i < 2021; i++ ) {
    v = isoWeeksInYear( i );
    console.log( 'The year %d has %d ISO weeks.', i, v );
}

CLI

Usage

Usage: isoweeksinyear [options] [year]

Options:

  -h,    --help                Print this message.
  -V,    --version             Print the package version.

Examples

$ isoweeksinyear
<number>

For a specific year,

$ isoweeksinyear 2015
53