moment-lunar
v0.0.4
Published
Moment.js plugin for chinese lunar calendar
Downloads
4,025
Maintainers
Readme
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
- install
$ npm install moment-lunar
- 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/[email protected]/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