README.md (2638B)
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 # isoWeeksInYear 22 23 > Determine the number of [ISO weeks][iso-week-date] in a year according to the [Gregorian calendar][gregorian-calendar]. 24 25 <section class="usage"> 26 27 ## Usage 28 29 ```javascript 30 var isoWeeksInYear = require( '@stdlib/time/iso-weeks-in-year' ); 31 ``` 32 33 #### isoWeeksInYear( \[value] ) 34 35 Returns the number of [ISO weeks][iso-week-date] in a year according to the [Gregorian calendar][gregorian-calendar]. 36 37 ```javascript 38 var num = isoWeeksInYear(); 39 // returns <number> 40 ``` 41 42 By default, the function returns the number of [ISO weeks][iso-week-date] in the current year (according to local time). To determine the number of [ISO weeks][iso-week-date] for a particular year, provide either a year or a [`Date`][date-object] object. 43 44 ```javascript 45 var num = isoWeeksInYear( new Date() ); 46 // returns <number> 47 48 num = isoWeeksInYear( 2015 ); 49 // returns 53 50 51 num = isoWeeksInYear( 2017 ); 52 // returns 52 53 ``` 54 55 </section> 56 57 <!-- /.usage --> 58 59 <section class="examples"> 60 61 ## Examples 62 63 <!-- eslint no-undef: "error" --> 64 65 ```javascript 66 var isoWeeksInYear = require( '@stdlib/time/iso-weeks-in-year' ); 67 68 var v; 69 var i; 70 71 for ( i = 0; i < 2021; i++ ) { 72 v = isoWeeksInYear( i ); 73 console.log( 'The year %d has %d ISO weeks.', i, v ); 74 } 75 ``` 76 77 </section> 78 79 <!-- /.examples --> 80 81 * * * 82 83 <section class="cli"> 84 85 ## CLI 86 87 <section class="usage"> 88 89 ### Usage 90 91 ```text 92 Usage: iso-weeks-in-year [options] [year] 93 94 Options: 95 96 -h, --help Print this message. 97 -V, --version Print the package version. 98 ``` 99 100 </section> 101 102 <!-- /.usage --> 103 104 <section class="examples"> 105 106 ### Examples 107 108 ```bash 109 $ iso-weeks-in-year 110 <number> 111 ``` 112 113 For a specific year, 114 115 ```bash 116 $ iso-weeks-in-year 2015 117 53 118 ``` 119 120 </section> 121 122 <!-- /.examples --> 123 124 </section> 125 126 <!-- /.cli --> 127 128 <section class="links"> 129 130 [iso-week-date]: https://en.wikipedia.org/wiki/ISO_week_date 131 132 [gregorian-calendar]: https://en.wikipedia.org/wiki/Gregorian_calendar 133 134 [date-object]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date 135 136 </section> 137 138 <!-- /.links -->