@stdlib/time-iso-weeks-in-year v0.2.1
isoWeeksInYear
Determine the number of ISO weeks in a year according to the Gregorian calendar.
Installation
npm install @stdlib/time-iso-weeks-in-year
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 );
}
See Also
@stdlib/time-iso-weeks-in-year-cli
: CLI package for use as a command-line utility.
Notice
This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
Community
License
See LICENSE.
Copyright
Copyright © 2016-2024. The Stdlib Authors.