所以我正在制作一个互动时间表,这是一个有两周时间表的学校,但是我无法确定我们目前是第一周还是第二周。这很复杂,好像你在第二周结束了一个半学期,它会忽略一周的学校,并在第一周继续学习。我似乎无法在我的生活中找到一种方法来实现这一点。我在Jason中定义了学年:
[
{
"day": {
"1": {
"type": "lesson",
"info": "1",
"start": "09:00",
"end": "10:00"
},
"2": {
"type": "lesson",
"info": "2",
"start": "10:00",
"end": "11:00"
},
"3": {
"type": "break",
"info": "break",
"start": "11:00",
"end": "11:20"
},
"4": {
"type": "lesson",
"info": "3",
"start": "11:20",
"end": "12:20"
},
"5": {
"type": "lesson",
"info": "4",
"start": "13:20",
"end": "14:10"
},
"6": {
"type": "lunch",
"info": "lunch",
"start": "12:20",
"end": "13:20"
},
"7": {
"type": "lesson",
"info": "5",
"start": "14:10",
"end": "15:10"
}
},
"terms": {
"1": {
"name": "auturm",
"1": {
"start": "07-09-2015",
"end": "23-10-2015"
},
"2": {
"start": "03-11-2015",
"end": "18-12-2015"
}
},
"2": {
"name": "spring",
"1": {
"start": "04-01-2016",
"end": "12-02-2016"
},
"2": {
"start": "22-02-2016",
"end": "01-04-2016"
}
},
"3": {
"name": "summer",
"1": {
"start": "19-04-2016",
"end": "27-05-2016"
},
"2": {
"start": "06-06-2016",
"end": "20-07-2016"
}
}
},
"breaks": [
"02-09-2015",
"02-09-2015",
"18-04-2016",
"21-07-2016",
"22-07-2016",
"25-07-2016",
"31-08-2015",
"25-03-2016",
"28-03-2016",
"02-05-2016"
]
}
一个示例时间表:
[
{
"week": {
"1": {
"1": {
"name": "monday",
"1": {
"subject": "Science",
"teacher": "CA",
"room": "S1"
},
"2": {
"subject": "English",
"teacher": "GF",
"room": "E1"
},
"3": {
"subject": "Maths",
"teacher": "KL",
"room": "A14"
},
"4": {
"subject": "History",
"teacher": "SH",
"room": "C18"
},
"5": {
"subject": "History",
"teacher": "SH",
"room": "C18"
}
},
"2": {
"name": "tuesday",
"1": {
"subject": "English",
"teacher": "GF",
"room": "E1"
},
"2": {
"subject": "Religious Education",
"teacher": "AB",
"room": "C13"
},
"3": {
"subject": "Maths",
"teacher": "DT",
"room": "A13"
},
"4": {
"subject": "Physical Education",
"teacher": "DV",
"room": "Gym"
},
"5": {
"subject": "Science",
"teacher": "AB",
"room": "S4"
}
},
"3": {
"name": "wednesday",
"1": {
"subject": "Geography",
"teacher": "RM",
"room": "C12"
},
"2": {
"subject": "Computer Science",
"teacher": "SR",
"room": "S7"
},
"3": {
"subject": "Product Design",
"teacher": "SOM",
"room": "D6"
},
"4": {
"subject": "Product Design",
"teacher": "SOM",
"room": "D6"
},
"5": {
"subject": "Maths",
"teacher": "KL",
"room": "A14"
}
},
"4": {
"name": "wednesday",
"1": {
"subject": "Geography",
"teacher": "RB",
"room": "C4"
},
"2": {
"subject": "Geography",
"teacher": "RB",
"room": "C4"
},
"3": {
"subject": "Computer Science",
"teacher": "SR",
"room": "C7"
},
"4": {
"subject": "English",
"teacher": "GF",
"room": "E1"
},
"5": {
"subject": "History",
"teacher": "SH",
"room": "C18"
}
},
"5": {
"name": "friday",
"1": {
"subject": "Maths",
"teacher": "DT",
"room": "A13"
},
"2": {
"subject": "Science",
"teacher": "SE",
"room": "S7"
},
"3": {
"subject": "Science",
"teacher": "CA",
"room": "S1"
},
"4": {
"subject": "English",
"teacher": "GF",
"room": "E1"
},
"5": {
"subject": "Physical Education",
"teacher": "DV",
"room": "Gym"
}
}
},
"2": {
"1": {
"name": "monday",
"1": {
"subject": "Science",
"teacher": "AB",
"room": "S4"
},
"2": {
"subject": "Science",
"teacher": "CA",
"room": "S1"
},
"3": {
"subject": "Maths",
"teacher": "DT",
"room": "A13"
},
"4": {
"subject": "English",
"teacher": "GF",
"room": "E1"
},
"5": {
"subject": "English",
"teacher": "GF",
"room": "E1"
}
},
"2": {
"name": "tuesday",
"1": {
"subject": "Science",
"teacher": "SE",
"room": "S7"
},
"2": {
"subject": "Product Design",
"teacher": "SOM",
"room": "D6"
},
"3": {
"subject": "Science",
"teacher": "AB",
"room": "S4"
},
"4": {
"subject": "Physical Education",
"teacher": "DV",
"room": "Gym"
},
"5": {
"subject": "Maths",
"teacher": "KL",
"room": "C3"
}
},
"3": {
"name": "wednesday",
"1": {
"subject": "Computer Science",
"teacher": "SR",
"room": "C7"
},
"2": {
"subject": "Computer Science",
"teacher": "SR",
"room": "S7"
},
"3": {
"subject": "Product Design",
"teacher": "SOM",
"room": "D6"
},
"4": {
"subject": "Product Design",
"teacher": "SOM",
"room": "D6"
},
"5": {
"subject": "English",
"teacher": "GF",
"room": "E1"
}
},
"4": {
"name": "Thursday",
"1": {
"subject": "Geography",
"teacher": "RM",
"room": "C12"
},
"2": {
"subject": "Geography",
"teacher": "RB",
"room": "C4"
},
"3": {
"subject": "History",
"teacher": "SH",
"room": "C18"
},
"4": {
"subject": "History",
"teacher": "SH",
"room": "C18"
},
"5": {
"subject": "Science",
"teacher": "SE",
"room": "S7"
}
},
"5": {
"name": "friday",
"1": {
"subject": "English",
"teacher": "GF",
"room": "E1"
},
"2": {
"subject": "Maths",
"teacher": "KL",
"room": "C3"
},
"3": {
"subject": "Science",
"teacher": "CA",
"room": "S1"
},
"4": {
"subject": "Computer Science",
"teacher": "SR",
"room": "C7"
},
"5": {
"subject": "Physical Education",
"teacher": "DV",
"room": "Gym"
}
}
}
}
}
PS。我没有任何问题,弄清楚当前的课程每天是什么,在一周之内,本周是什么。
编辑:为了清楚起见我试图获得一个将返回当前周(1/2)的函数,例如今天(本周)应返回1