JavaScript calculates world full symmetry day

Source: Internet
Author: User

Today is the 2011-11-02 day, Weibo ah, g+ ah what is the world is completely symmetrical day, also said how many years of the encounter. Write a JavaScript applet below to see if it's really n-year. The calculation ranges from 2000 to 3,000 A.D. Lanxi County Quwan Home Photography

Noun Explanation: The world is completely symmetrical day, refers to the Gregorian calendar date in the dates of the full symmetry of the date, this day friends can send each other blessings at the same time to let everyone sigh of the precious times.

JavaScript Code:
<input type= "button" value= "Calculate World Full symmetry day" id= "compute"/><div id= "result" ></div> <script> /** * Change the date into a standard 8-bit format, such as 20111102 * divide it into four segments 20 11 11 02 for the century, year, month, day * time complexity of the algorithm is O (N3), and from the last four bits, the month and day can get the final knot More efficient * Because the February mantissa of the leap year is 9, which exceeds the long history of mankind, so there is no need to consider */;;(            function () {var thedatelist=[];            The century maximum Var maxforcentury=30 that appears palindrome day;            The century minimum var minforcentury=20 that appears palindrome day;            May appear palindrome day of the maximum value, here only rough processing Var maxforyear=21;                var maxforday=31;//does not exclude leap year for (Var i=1;i<=12;i++) {var stdyear,stdday;                var stdmonth=getstandarddate (i);                /* IF (getreversedate (stdmonth) >maxforday) {continue;                } */Maxforday=getdate (i);                    for (Var k=1;k<maxforday;k++) {Stdday =getstandarddate (k); Stdyear=getreverseDate (Stdmonth+stdday); if (parseint (Getreversedate (Stdday), ten) >=minforcentury && parseint (getreversedate (Stdday)                            , ten) <maxforcentury) Thedatelist.push (Stdyear+stdmonth+stdday)} } thedatelist.sort (); Sort var result = document.getElementById ("result"), var str = "", var btn = document.getElementById ("Compute"); Btn.onclick = function () {for (Var i=0;i<thedatelist.length;i++) {Console.log (thedatelist[i]); str + = Thedatelist[i]                        + "<br/>"; result.innerhtml = str;}}             Console.log (' Total%d records ', thedatelist.length)/** * Number of days of current month based on month * @param {int} val month            * @return {int} */function GetDate (val) {return val%2==0?30:31; /** * Replace a date value less than 10 with a standard 8-bit date value * @param {int} val month or date * @return {string} standard  Format */          Function Getstandarddate (val) {if (val<10) {return ' 0 ' +val;            } return val.tostring ();             /** * Reverse Date * @param {string} standard format for date month or date * @return {string} inverted standard format            */function Getreversedate (date) {return Date.split (""). Reverse (). Join ("");    }        })(); </script>

JavaScript calculates world full symmetry day

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.