Examples of using the "Calendar-Converter" and "JavaScript" plug-ins

Source: Internet
Author: User

Calendar-Converter is a simple plug-in that may only be used by Chinese applications or websites. The plug-in function is to convert the date and time between the Gregorian Calendar and the lunar Calendar.

Example

First introduce the plug-in file

<Script src = "js/calendar-converter.js"> </script>
Then instantiate the plug-in object and pass a time object.

Var cc = new CalendarConverter;
Cc. solar2lunar (new Date (2011, 0, 3); ---> 2010,11, 29
Cc. lunar2solar (new Date (2010, 10, 29); ----> 2011, 1, 3
If the lunar calendar is converted to the Gregorian calendar, if January is the leap month of that year, an additional parameter is required to obtain the correct Gregorian calendar date.

Cc. solar2lunar (new Date (2012, 4, 27); ---> 7 at the beginning of May 2012, where isLeap is true, which indicates April
Cc. lunar2solar (new Date (2012, 3, 7) ---> error Time: 2012, 4, 27
Cc. lunar2solar (new Date (2012, 3, 7), true) --> correct: 2012, 5, 27
Optional parameter

Result :{
CDay: "Wuyun"
, CMonth: "Ding Wei"
, CYear: "Chen"
, IsLeap: false // whether the month is a leap month
, LDay: 18
, LMonth: 6
, LYear: 2012
, LunarDay: "18"
, LunarFestival :""
, LunarMonth: "6"
, LunarYear: "Dragon"
, SDay: 5
, SMonth: 8
, SYear: 2012, solarFestival: "// Festival (Festivals)
, SolarTerms: "" // solar saving
, Week: "day" // day of the week
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.