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

moonbeams

v2.0.3

Published

Astronomical calculation library

Downloads

10,002

Readme

#Moonbeams

Javscript library for doing astronomical calculations

Use

var moonbeams = require('moonbeams');

var spring95 = moonbeams.season(0, 1995);

API reference

Only methods backed up by tests will be listed here

calendarToJd moonbeams.calendarToJd(year, month, day)

Convert a given year, month, and day into a decimal julian day Year and month should be integers, day can be a decimal. To convert hours, minutes, and seconds into decimal see hmsToDay

Cannot convert from a date that would result in a negative julian day

jdToCalendar moonbeams.jdToCalendar(jd)

Convert a given decimal julian day into a calendar day. Given julian day must be positive. Returns an object with year, month, and day attributes. day will be a decimal you can pass to dayToHms to get the hours, minutes, and seconds from.

hmsToDay moonbeams.hmsToDay(hour, minute, second)

Convert a given hour, minute, and second to decimal. Second can be a decimal to represent precision higher than 1 second.

var day = 8;
var hour = 13;
var minute = 30;
var second = 45.2;
var fullDay = day + moonbeams.hmsToDay(hour, minute, second);
//fullDay will now be `8.563...`

dayToHms moonbeams.dayToHms(day)

Retrieve the hour, minute, and second from the decimal portion of a day. Returns an object with attributes hour, minute, and second. Second may be a decimal number.

hmsToRightAscention moonbeams.hmsToRightAscention(hour, minute, arcsecond)

Convert a given hour, minute, and arcsecond to right ascention. Second can be a decimal to represent precision higher than 1 arcsecond.

rightAscentionToHms moonbeams.rightAscentionToHms(rightAscention)

Convert a given decimal right ascention into hours, minutes, and (arc)seconds. Returns an object with attributes for hour, minute, and second. Second may be a decimal number.

INT moonbeams.INT(number)

Returns the integer portion of a given decimal number. This is different than Math.floor as it doesn't round down, but rounds towards zero

T moonbeams.T(jd)

Returns the current julian cycle, aka the julian cycle since Jan 1, 2000

So, moonbeams.INT(4.999) is 4 and moonbeams.INT(-4.999) is -4

isLeapYear moonbeams.isLeapYear(year)

Takes an integer year and returns true if that year is a leap year

season moonbeams.season(seasonIndex, year)

dayOfWeek moonbeams.dayOfWeek(jd)

Returns integer day of week (0-6 where 0 is Sunday) for given julian day

dayOfYear moonbeams.dayOfYear(jd)

Returns integer day of year (1-365 or 366) for given julian day

yearDayToCalendar moonbeams.yearDayToCalendar(yearDay, year)

Calculate the calendar day of a given day of the year and year. Returns an object with year, month, and day attributes.

meanSiderealTime moonbeams.meanSiderealTime(jd)

Returns the mean sidereal Time at Greenwich for given julian day

Find the decimal julian day that a given season starts in a given year. seasonIndex is as follows

  • 0 - March Equinox
  • 1 - June Solstice
  • 2 - September Equinox
  • 3 - December Solstice

Year must be between -1000 and 3000.

Notes

Years should be integers, positive or negative. BC years are simply negative years, for example the year 585 BC is really -584.

#License MIT

Credit

Most of the calculations in this library are from Astronomical Algorythms by John Meeus without which libraries like this would likely never exist.

Unless specifically stated otherwise, all julian days are in dynamical time and can be decimal