time-to-botec

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

README.md (2765B)


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