@stdlib/time-quarter-of-year
v0.2.2
Published
Determine the quarter of the year.
Downloads
74
Readme
quarterOfYear
Determine the quarter of the year.
Installation
npm install @stdlib/time-quarter-of-year
Usage
var quarterOfYear = require( '@stdlib/time-quarter-of-year' );
quarterOfYear( [month] )
Returns the quarter of the year.
var q = quarterOfYear();
// returns <number>
By default, the function returns the quarter of the year for the current month in the current year (according to local time). To determine the quarter for a particular month, provide either a month or a Date
object.
var q = quarterOfYear( new Date() );
// returns <number>
q = quarterOfYear( 4 );
// returns 2
A month
may be either a month's integer value, three letter abbreviation, or full name (case insensitive).
var q = quarterOfYear( 4 );
// returns 2
q = quarterOfYear( 'April' );
// returns 2
q = quarterOfYear( 'apr' );
// returns 2
Examples
var quarterOfYear = require( '@stdlib/time-quarter-of-year' );
var months;
var q;
var i;
months = [
'January',
'February',
'March',
'April',
'May',
'June',
'July',
'August',
'September',
'October',
'November',
'December'
];
for ( i = 0; i < months.length; i++ ) {
q = quarterOfYear( months[ i ] );
console.log( 'The month of %s is in Q%d.', months[ i ], q );
}
See Also
@stdlib/time-quarter-of-year-cli
: CLI package for use as a command-line utility.@stdlib/time-day-of-year
: determine the day of the year.
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.