README.md (2715B)
1 <!-- 2 3 @license Apache-2.0 4 5 Copyright (c) 2018 The Stdlib Authors. 6 7 Licensed under the Apache License, Version 2.0 (the "License"); 8 you may not use this file except in compliance with the License. 9 You may obtain a copy of the License at 10 11 http://www.apache.org/licenses/LICENSE-2.0 12 13 Unless required by applicable law or agreed to in writing, software 14 distributed under the License is distributed on an "AS IS" BASIS, 15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 See the License for the specific language governing permissions and 17 limitations under the License. 18 19 --> 20 21 # quarterOfYear 22 23 > Determine the quarter of the year. 24 25 <section class="usage"> 26 27 ## Usage 28 29 ```javascript 30 var quarterOfYear = require( '@stdlib/time/quarter-of-year' ); 31 ``` 32 33 #### quarterOfYear( \[month] ) 34 35 Returns the quarter of the year. 36 37 ```javascript 38 var q = quarterOfYear(); 39 // returns <number> 40 ``` 41 42 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`][date-object] object. 43 44 ```javascript 45 var q = quarterOfYear( new Date() ); 46 // returns <number> 47 48 q = quarterOfYear( 4 ); 49 // returns 2 50 ``` 51 52 A `month` may be either a month's integer value, three letter abbreviation, or full name (case insensitive). 53 54 ```javascript 55 var q = quarterOfYear( 4 ); 56 // returns 2 57 58 q = quarterOfYear( 'April' ); 59 // returns 2 60 61 q = quarterOfYear( 'apr' ); 62 // returns 2 63 ``` 64 65 </section> 66 67 <!-- /.usage --> 68 69 <section class="examples"> 70 71 ## Examples 72 73 <!-- eslint no-undef: "error" --> 74 75 ```javascript 76 var quarterOfYear = require( '@stdlib/time/quarter-of-year' ); 77 78 var months; 79 var q; 80 var i; 81 82 months = [ 83 'January', 84 'February', 85 'March', 86 'April', 87 'May', 88 'June', 89 'July', 90 'August', 91 'September', 92 'October', 93 'November', 94 'December' 95 ]; 96 97 for ( i = 0; i < months.length; i++ ) { 98 q = quarterOfYear( months[ i ] ); 99 console.log( 'The month of %s is in Q%d.', months[ i ], q ); 100 } 101 ``` 102 103 </section> 104 105 <!-- /.examples --> 106 107 * * * 108 109 <section class="cli"> 110 111 ## CLI 112 113 <section class="usage"> 114 115 ### Usage 116 117 ```text 118 Usage: quarter-of-year [options] [month] 119 120 Options: 121 122 -h, --help Print this message. 123 -V, --version Print the package version. 124 ``` 125 126 </section> 127 128 <!-- /.usage --> 129 130 <section class="examples"> 131 132 ### Examples 133 134 ```bash 135 $ quarter-of-year 136 <number> 137 ``` 138 139 For a specific month, 140 141 ```bash 142 $ quarter-of-year 4 143 2 144 ``` 145 146 </section> 147 148 <!-- /.examples --> 149 150 </section> 151 152 <!-- /.cli --> 153 154 <section class="links"> 155 156 [date-object]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date 157 158 </section> 159 160 <!-- /.links -->