Skip to content

A lunar calendar(used in korea, chinese, ...) extension for moment.js.

License

Notifications You must be signed in to change notification settings

Luavis/moment-lunar

Repository files navigation

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

About

A lunar calendar(used in korea, chinese, ...) extension for moment.js.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published