123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- /**
- * Created by chen on 2017/6/27.
- */
- !function (w) {
- function a(w){
- this.yaer=new Date().getFullYear();
- this.json=[];
- this.hours=[];
- this.days=0;
- this.nowyear=0;
- this.hour=0;
- }
- a.prototype={
- constructor:a,
- init:function(){
- this.createJSON();
- this.createHours();
- },
- createJSON:function(){
- for(var i=0;i<10;i++){
- this.nowyear=this.yaer+i;
- this.json[i]={
- "name":this.nowyear,
- "sub":[]
- };
- for(var j=0;j<12;j++){
- this.json[i]['sub'][j]={
- "name":(j+1),
- "sub":[]
- }
- this.days=this.getDay(this.nowyear,j+1);
- for(var n=0;n<this.days;n++){
- this.json[i]['sub'][j]['sub'][n]={
- "name":n+1
- }
- }
- }
- }
- },
- getDay:function (year,month) {
- if(!(year%4)&&year%100){
- if(month=="2") {
- return 29;
- }else {
- return this.otherDay(month);
- }
- }else {
- if(!(year%400)&&$month=="2"){
- return 29;
- }else {
- return this.otherDay(month);
- }
- }
- },
- createHours:function () {
- for(var i=0;i<24;i++){
- this.hours[i]={
- "name":i+"时",
- "sub":[]
- };
- for(var j=0;j<60;j++){
- this.hours[i]['sub'][j]={
- "name":j+"分",
- "sub":[]
- }
- }
- }
- },
- otherDay:function (month) {
- switch (month){
- case 1: return 31;break;
- case 2: return 28;break;
- case 3: return 31;break;
- case 4: return 30;break;
- case 5: return 31;break;
- case 6: return 30;break;
- case 7: return 31;break;
- case 8: return 31;break;
- case 9: return 30;break;
- case 10: return 31;break;
- case 11: return 30;break;
- case 12: return 31;break;
- }
- }
- }
- var timeJSON=new a();
- timeJSON.init();
- w.timeJson=timeJSON.json;
- w.hours=timeJSON.hours;
- }(window)
|