daysInYear

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

Usage

var daysInYear = require( '@stdlib/time/days-in-year' );

daysInYear( [value] )

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

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

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

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

num = daysInYear( 2000 );
// returns 366

num = daysInYear( 2017 );
// returns 365

Examples

var daysInYear = require( '@stdlib/time/days-in-year' );

var v;
var i;

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

CLI

Usage

Usage: daysinyear [options] [year]

Options:

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

Examples

$ daysinyear
<number>

For a specific year,

$ daysinyear 2016
366