{"id":7,"date":"2009-07-07T18:15:48","date_gmt":"2009-07-07T10:15:48","guid":{"rendered":"http:\/\/blog.garphy.com\/?p=7"},"modified":"2010-08-17T19:34:07","modified_gmt":"2010-08-17T11:34:07","slug":"%e5%8e%9f%e5%88%9b%e5%a4%a9%e6%95%b0%e5%80%92%e8%ae%a1%e6%97%b6%e8%84%9a%e6%9c%ac","status":"publish","type":"post","link":"https:\/\/blog.garphy.com\/?p=7","title":{"rendered":"[\u539f\u521b]\u5929\u6570\u5012\u8ba1\u65f6\u811a\u672c"},"content":{"rendered":"<p>\u4e9a\u8fd0\u8fd8\u6709\u4e00\u5e74\u5c31\u5f00\u59cb\u4e86\uff0c\u5e94\u9886\u5bfc\u4e4b\u9700\uff0c\u5c31\u81ea\u5df1\u5199\u4e86\u4e00\u4e2a\u5012\u8ba1\u65f6\u811a\u672c\uff0c\u53d1\u4e0a\u6765\u5206\u4eab\u4e0b\uff0c\u6709\u8bf7\u5404\u4f4d\u5927\u867e\u6307\u70b9&#8230;<\/p>\n<p>\u57fa\u672c\u601d\u8def\u662f\u7b97\u6700\u540e\u4e00\u5e74\u7684\u5929\u6570\uff0c\u518d\u8ba1\u7b97\u76f8\u5dee\u591a\u5c11\u5e74\uff0c\u5f97\u51fa\u603b\u7684\u5929\u6570\u5dee\uff0c\u7136\u540e\u518d\u8ba1\u65f6<\/p>\n<pre class=\"brush:javascript\"> \r\n<div id=\"time\"><\/div>\r\n<script type=\"text\/javascript\">\r\n\/*\r\nname: \u5929\u6570\u5012\u8ba1\u65f6\r\nver: 0.2\r\nauthor: Garphy\r\nemail: garphy55@gmail.com\r\n*\/\r\n\/\/=======================\u53c2\u6570\u914d\u7f6e\u533a\u57df\r\nvar oneday = '2010-11-12';     \/\/\u65e5\u671f\uff0c\u683c\u5f0f y-m-d\r\nvar onetime = '20:00:00';     \/\/\u65f6\u95f4\uff0c\u683c\u5f0f hh:mm:ss\r\nvar show_ms = 1;      \/\/\u662f\u5426\u663e\u793a\u6beb\u79d2\r\nvar preText = '\u8ddd\u79bb\u5e7f\u5dde\u4e9a\u8fd0\u4f1a\u5f00\u5e55\u8fd8\u6709 '; \/\/\u524d\u7f00\u6587\u5b57\r\nvar tips = '\u70ed\u70c8\u5e86\u795d\u4e9a\u8fd0\u4f1a\u6b63\u5f0f\u5f00\u5e55\uff01';  \/\/\u5230\u671f\u63d0\u793a\u6587\u5b57\r\n\/\/=======================\u53c2\u6570\u914d\u7f6e\u533a\u57df\r\nvar date = oneday.split('-');\r\nvar time = onetime.split(':');\r\nvar y = parseInt(date[0]),m=parseInt(date[1]),d=parseInt(date[2]);\r\nvar hh = parseInt(time[0]),mm=parseInt(time[1]),ss=parseInt(time[2]);\r\n\/\/var y=2010,m=11,d=12,hh=20,mm=0,ss=0;\r\nvar f=show_ms?1:1000;\r\nvar o = document.getElementById('time');\r\n\/\/\u95f0\u5e74\u5224\u65ad\r\nfunction yearType(y){ return ( ( y%4 == 0 &amp;&amp; y%100 != 0) || y%400 == 0 ) ? 1:0;}\r\n\/\/\u8ba1\u7b97\u5f53\u5e74\u6708\u4efd\u5929\u6570\u5dee\r\nfunction countDays(from,to,year){\r\n var eachdays = [0,31,28,31,30,31,30,31,31,30,31,30,31];\r\n if(yearType(year))eachdays[2]=29;\r\n var days = 0;\r\n for(i=from;i<=to;i++) days += eachdays[i];\r\n return days;\r\n}\r\n\/\/\u683c\u5f0f\u5316\u65f6\u95f4\u8f93\u51fa\r\nfunction format(n){ return n<10?'0'+n:n;}\r\nfunction count(){\r\n var t = new Date();\r\n var cy=t.getFullYear(), cm=t.getMonth()+1, cd=t.getDate(), chh=t.getHours(), cmm=t.getMinutes(), css=t.getSeconds(), cms=t.getMilliseconds(); \r\n var num=0;\r\n if(y>cy){\r\n  num+=365*(y-cy-1);\r\n  for(i=cy;i<y;i++){if(yearType(i))num++;}     \/\/\u95f0\u5e74\u52a01\r\n  if(yearType(cy) &amp;&amp; parseInt(cm+''+format(cd))>=229) num--; \/\/\u6392\u9664\u5f00\u5934\u95f0\u5e74\u60c5\u51b5\r\n  if(yearType(y-1) &amp;&amp; parseInt(cm+''+format(cd))<229) num--; \/\/\u6392\u9664\u5c3e\u5e74\u95f0\u5e74\u60c5\u51b5\r\n  num+=countDays(cm,12,y-1) + countDays(1,m-1,y); \r\n }else{\r\n  num+=countDays(cm,m-1,y);\r\n }\r\n num = num - cd + d;\r\n var seconds = ss - css;\r\n  if(ss<css){ seconds += 60; cmm++;}\r\n var mins = mm - cmm;\r\n  if(mm<cmm){ mins += 60; chh++;} \r\n var hours = hh-chh;\r\n  if(hh<chh){ hours += 24; num--;}\r\n \r\n if(num>=0 &amp;&amp; hours>=0 &amp;&amp; mins>=0 &amp;&amp; seconds >=0){\r\n  o.innerHTML = preText;\r\n  if(num>0)o.innerHTML += num+'\u5929 ';\r\n  o.innerHTML += format(hours)+':'+format(mins)+':'+format(seconds);\r\n  if(show_ms){\r\n   mss = 999-cms;\r\n   if(mss<10)\r\n    o.innerHTML+=':00'+ mss;\r\n   else if(mss<100)\r\n    o.innerHTML+=':0'+ mss;\r\n   else\r\n    o.innerHTML+=':'+ mss;\r\n  }\r\n  timer = setTimeout( count,f);\r\n }else{\r\n  o.innerHTML = tips;\r\n  clearTimeout(timer);\r\n } \r\n}\r\nvar timer = setTimeout( count,f);\r\n<\/script>\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u4e9a\u8fd0\u8fd8\u6709\u4e00\u5e74\u5c31\u5f00\u59cb\u4e86\uff0c\u5e94\u9886\u5bfc\u4e4b\u9700\uff0c\u5c31\u81ea\u5df1\u5199\u4e86\u4e00\u4e2a\u5012\u8ba1\u65f6\u811a\u672c\uff0c\u53d1\u4e0a\u6765\u5206\u4eab\u4e0b\uff0c\u6709\u8bf7\u5404\u4f4d\u5927\u867e\u6307\u70b9&#8230;<\/p>\n<p>\u57fa\u672c\u601d\u8def\u662f\u7b97\u6700\u540e\u4e00\u5e74\u7684\u5929\u6570\uff0c\u518d\u8ba1\u7b97\u76f8\u5dee\u591a\u5c11\u5e74\uff0c\u5f97\u51fa\u603b\u7684\u5929\u6570\u5dee\uff0c\u7136\u540e\u518d\u8ba1\u65f6<\/p>\n<p>\u8be6\u7ec6\u4ee3\u7801\u5982\u4e0b&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,8],"tags":[4],"class_list":["post-7","post","type-post","status-publish","format-standard","hentry","category-front-end","category-8","tag-js"],"_links":{"self":[{"href":"https:\/\/blog.garphy.com\/index.php?rest_route=\/wp\/v2\/posts\/7","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.garphy.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.garphy.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.garphy.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.garphy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7"}],"version-history":[{"count":10,"href":"https:\/\/blog.garphy.com\/index.php?rest_route=\/wp\/v2\/posts\/7\/revisions"}],"predecessor-version":[{"id":20,"href":"https:\/\/blog.garphy.com\/index.php?rest_route=\/wp\/v2\/posts\/7\/revisions\/20"}],"wp:attachment":[{"href":"https:\/\/blog.garphy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.garphy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.garphy.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}