npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

sun-time

v1.0.2

Published

Calculator of sunrise time as well as sunset time according to location(Long.,lat.) or city name.

Downloads

35

Readme

sun-time :

Calculator of sunrise and sunset according to location(Long.,lat.) or city name .

Install :

  npm install sun-time;

If you want to increase the potential of finding city in local-database of city-coordinates , we recommend to install db-ctiy package .

npm install db-city;

However, db-city is a huge package (144 Mo) since it handles more than 3 Million cities . (Read more about "db-city" ) & how to avoid RAM overload .

Anyway, sun-time has more than 23k local cities .

How to use :

 var sun=require('sun-time');

1. sun(LAT,LONG,ELEVATION) :

  • Latitude is a real number between -90 and 90,

  • longitude is between -180 and 180

  • elevation is a positive number specifying the height in meters with respect to the surrounding terrain. The elevation parameter is optional.

  • Return an object with 2 attributs : i.e : {rise:"",set:""}

  • May returns an array of objects if more than one city have the same name.

    Use cases :

     sun(24.68773,46.72185)
       //->i am in Riyadh
      sun(24.68773,46.72185,20)
       // i am in mountain with height=20m

2. sun([LAT,LONG,ELEVATION],date) :

You can retrieve sun's times according to date .

  • date : You can use new Date() to specify today. Date can be also entered as a triple [year, month, day]. For example, [2009, 2, 26] specifies February 26, 2009.

    Since  `x-class` is one of `sun-time` dependencies , `Date.daysAgo`, `Date.daysNext`,`yesterday`,`tomorrow` functions are available as  `static` methods under `Date` class.

Use cases :

```js
   sun([24,46],new Date())
  //-> new Date() is the default
   sun([24,46],[1989,11,25])
   // --> sun times at Nov 25,1989
   sun([24,46],Date.daysAgo(7));
   //--> before 1 week from now

```

3. sun([LAT,LONG,ELEVATION],date,{format:"24h",tz:3,dst:0}) :

sun method is still overloaded by some options :

  • format (DEFAULT: 24h):

    Output time format, according to the following table:

| Format | Description | Example | |---------|-------------------------------|---------| | 24h | 24-hour time format | 17:35 | | 12h | 12-hour time format | 5:35 pm | | 12hNS | 12-hour format with no suffix | 5:35 | | Float | Floating point number | 17.35 |

  • tz (DEFAULT : hours offset of System % GMT):

    The difference to Greenwich time (GMT) in hours. If omitted or set to "auto", timezone is extracted from the system.

  • dst (DEFAULT: 0):

    Daylight Saving Time: 1 if date is in daylight saving time, 0 otherwise. (summer time->1).

3. sun(CITY_NAME) :


       sun('Riyadh')
       //--> if city in the same country of system --> Works!
       //--------------
       //--> else, in this version, add timezone ("tz")
       sun('Tunis',new Date(),{tz:1})
       // "1" -> because Tunis (GMT+1)

       sun('கிரனாதா') // === sun("Granada")

The last instruction proves that sun-time supports i18n

     sun('London');
     // is the same
     sun('لندن')  ;

4. Get Directly sunrise or sunset

sun.rise('Mecaa');
sun.set('Newyork');

sun.rise & sun.set are overloaded such as sun itself.

License :

  Copyright (c) 2016 Abdennour TOUMI <http://abdennoor.com>

  Permission is hereby granted, free of charge, to any person obtaining a copy
  of this software and associated documentation files (the "Software"), to deal
  in the Software without restriction, including without limitation the rights
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  copies of the Software, and to permit persons to whom the Software is
  furnished to do so, subject to the following conditions:

  The above copyright notice and this permission notice shall be included in
  all copies or substantial portions of the Software.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  THE SOFTWARE.