README.md (3050B)
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 # dayOfQuarter 22 23 > Determine the day of the quarter. 24 25 <section class="usage"> 26 27 ## Usage 28 29 ```javascript 30 var dayOfQuarter = require( '@stdlib/time/day-of-quarter' ); 31 ``` 32 33 #### dayOfQuarter( \[month\[, day, year]] ) 34 35 Returns the day of the quarter. 36 37 ```javascript 38 var num = dayOfQuarter(); 39 // returns <number> 40 ``` 41 42 By default, the function returns the day of the quarter for the current date (according to local time). To determine the day of the quarter for a particular day, provide `month`, `day`, and `year` arguments. 43 44 ```javascript 45 var num = dayOfQuarter( 12, 31, 2016 ); 46 // returns 92 47 ``` 48 49 A `month` may be either a month's integer value, three letter abbreviation, or full name (case insensitive). 50 51 ```javascript 52 var num = dayOfQuarter( 12, 31, 2016 ); 53 // returns 92 54 55 num = dayOfQuarter( 'dec', 31, 2016 ); 56 // returns 92 57 58 num = dayOfQuarter( 'december', 31, 2016 ); 59 // returns 92 60 ``` 61 62 The function also supports providing a [`Date`][date-object] object. 63 64 ```javascript 65 var num = dayOfQuarter( new Date() ); 66 // returns <number> 67 ``` 68 69 </section> 70 71 <!-- /.usage --> 72 73 <section class="examples"> 74 75 ## Examples 76 77 <!-- eslint no-undef: "error" --> 78 79 ```javascript 80 var quarterOfYear = require( '@stdlib/time/quarter-of-year' ); 81 var dayOfQuarter = require( '@stdlib/time/day-of-quarter' ); 82 83 var months; 84 var day; 85 var yr; 86 var q; 87 var v; 88 var i; 89 90 months = [ 91 'January', 92 'February', 93 'March', 94 'April', 95 'May', 96 'June', 97 'July', 98 'August', 99 'September', 100 'October', 101 'November', 102 'December' 103 ]; 104 105 yr = 2016; 106 day = 9; 107 108 for ( i = 0; i < months.length; i++ ) { 109 q = quarterOfYear( months[ i ] ); 110 v = dayOfQuarter( months[ i ], day, yr ); 111 console.log( 'In the year %d, %s %d is day number %d of Q%d.', yr, months[ i ], day, v, q ); 112 } 113 ``` 114 115 </section> 116 117 <!-- /.examples --> 118 119 * * * 120 121 <section class="cli"> 122 123 ## CLI 124 125 <section class="usage"> 126 127 ### Usage 128 129 ```text 130 Usage: day-of-quarter [options] [<month> <day> <year>] 131 132 Options: 133 134 -h, --help Print this message. 135 -V, --version Print the package version. 136 ``` 137 138 </section> 139 140 <!-- /.usage --> 141 142 <section class="examples"> 143 144 ### Examples 145 146 ```bash 147 $ day-of-quarter 148 <number> 149 ``` 150 151 For a specific date, 152 153 ```bash 154 $ day-of-quarter 12 31 2016 155 92 156 ``` 157 158 </section> 159 160 <!-- /.examples --> 161 162 </section> 163 164 <!-- /.cli --> 165 166 <section class="links"> 167 168 [date-object]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date 169 170 </section> 171 172 <!-- /.links -->