time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

README.md (3167B)


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