moment-lunar
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

NPM version MIT License

moment-lunar

Moment-lunar is moment.js plugin for chinese lunar calendar.

What is chinese lunar calendar?

A lunar calendar is a calendar based upon cycles of the Moon's phases (synodic months), in contrast to solar calendars based solely upon the solar year. A purely lunar calendar is also distinguished from lunisolar calendars whose lunar months are brought into alignment with the solar year through some process of intercalation. The details of when months begin varies from calendar to calendar, with some using new, full, or crescent moons and others employing detailed calculations. more

How to use

Webpack

  1. install
$ npm install moment-lunar
  1. import
import moment from 'moment';
import 'moment-lunar';
 
// convert to 1995-02-09 (1995/03/09 was 1995/02/29 in lunar calendar)
moment().year(1995).month(2).date(9).lunar().format('YYYY-MM-DD');
// get lunar new year's day
moment().year(2017).month(0).date(1).solar().format('YYYY-MM-DD');

Browser

<html>
    <!-- ... -->
    <body>
    <!-- ... -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment.min.js"></script> 
    <script src="https://unpkg.com/moment-lunar@0.0.4/moment-lunar.min.js"></script> 
    <script>
        // convert to 1995-02-09 (1995/03/09 was 1995/02/29 in lunar calendar)
        moment().year(1995).month(2).date(9).lunar().format('YYYY-MM-DD');
        // get lunar new year's day
        moment().year(2017).month(0).date(1).solar().format('YYYY-MM-DD');
    </script> 
    <!-- ... -->
    </body>
</html>

License

MIT

Package Sidebar

Install

npm i moment-lunar

Weekly Downloads

984

Version

0.0.4

License

MIT

Unpacked Size

21.4 kB

Total Files

7

Last publish

Collaborators

  • luavis