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

lunar-date-calculator

v1.1.2

Published

converts between lunar and solar dates

Downloads

17

Readme

lunar-date-calculator

lunar-date-calculator is a Javascript library for converting the date to the solar date in the current or any target year.

Installation

Use 'npm' to install the package.

npm i lunar-date-calculator

Definition

Lunar Calendar

A lunar calendar is a calendar based on the monthly cycles of the Moon's phases (synodic months, lunations), in contrast to solar calendars, whose annual cycles are based only directly on the solar year.

From wikipedia

Solar Calendar

A solar calendar is a calendar whose dates indicate the season or almost equivalently the apparent position of the Sun relative to the stars. The Gregorian calendar, widely accepted as a standard in the world, is an example of a solar calendar.

From wikipedia

Usage

fromSolarDate(solarYear, solarMonth, solarDay, targetYear = currentYear)

This function converts dates two times to get the solar date in the currentYear or any targetYear.

A targetYear is an optional parameter so that if targetYear is undefined, the default value is currentYear.

First, it converts the solar date to the lunar date in solarYear.

If targetYear is defined, it converts the caculated lunar date to the solar date in the targetYear.

Otherwise, it converts the lunar date to the solar date in currentYear.

import lunaDateCalculator from 'lunar-date-calculator';

// convert solar to lunar date in the current year (default value)
const solar2CurrentLunar = lunaDateCalculator.fromSolarDate(2007, 4, 18);
// output: { year: 2022, month: 4, day: 2 }

// convert solar in the future to lunar date in the target year
const solarInFuture2TargetLunar = lunaDateCalculator.fromSolarDate(2007, 4, 18, 1999);
// output: { year: 1999, month: 4, day: 17 }

// convert solar in the past to lunar date in the target year
const solarInPast2TargetLunar = lunaDateCalculator.fromSolarDate(2019, 4, 18, 2021);
// output: { year: 2021, month: 4, day: 13 }

fromLunarDate(lunarYear, lunarMonth, lunarDay, targetYear = currentYear)

This function converts the lunar date to the solar date in the currentYear or any targetYear.

A targetYear is an optional parameter so that if targetYear is undefined, the default value is currentYear.

import lunaDateCalculator from 'lunar-date-calculator';

// convert lunar to lunar date in the current year (default value)
const lunar2CurrentLunar = lunaDateCalculator.fromLunarDate(2007, 5, 15);
// output: { year: 2022, month: 6, day: 13 }

// convert lunar in the future to lunar date in the target year
const lunarInFuture2TargetLunar = lunaDateCalculator.fromLunarDate(2007, 5, 15, 1999);
// output: { year: 1999, month: 6, day: 28 }

// convert lunar in the past to lunar date in the target year
const lunarInPast2TargetLunar = lunaDateCalculator.fromLunarDate(2007, 5, 15, 2019);
// output: { year: 2019, month: 6, day: 17 }