Coder Social home page Coder Social logo

school-cal's Introduction

Go Report Card Build Status License: MIT Documentation

Example

using go mod

package main

import (
	"encoding/json"
	"fmt"
	"github.com/QSCTech/school-cal"
)

func main() {
	cal := schoolcal.NewCalendar(nil)
	data, _ := json.Marshal(cal.GetSchoolYears())
	fmt.Println(string(data))
}

Options

You can configure Calendar by delivering CalendarOption into NewCalendar

Data Sample

{
	"2015-2016": {
		// 日期(实际上是时间,为了支持半天调课)使用 ISO 8601 标准便于解析。
		// 2015年8月10日0时0分东8区。
		"start": "2015-08-10T00:00+08:00",
		// 到 end 为止,不包括 end 代表的这一天,即左闭右开区间的惯例。
		"end": "2016-08-01T00:00+08:00",
		"semesters": {
			// 学期见于校历表头和教务系统课程列表过滤器。
			// SM:Summer Mini,夏季短学期
			// AW:Autumn-Winter,秋冬长学期
			// Au:Autumn,秋季学期
			// Wi:Winter,冬季学期
			// WM:Winter Mini,冬季短学期(寒假)
			// SS:Spring-Summer,春夏学期
			// Sp:Spring,春季学期
			// Su:Summer,夏季学期
			// ST:Summer Tiny,夏季小学期
			"AW": {
				"start": "2015-09-14T00:00+08:00",
				"end": "2016-01-24T00:00+08:00",
				// 当前学期是否从第 0 周开始,对排课算法有影响。
				"startsWithWeekZero": false
			}
			// ...
		},
		"holidays": [
			{
				// 不上课即视作放假,校历是为手机站排课设计。
				"name": "春学期考试周",
				"start": "2016-04-23T00:00+08:00",
				// 左闭右开,不包含这天,4-23~27。
				"end": "2016-04-28T00:00+08:00"
			}
			// ...
		],
		//"term" 字段表示需要调整的课程,可针对小学期调课,“无筛选” 为兼容以前的调课逻辑,不对课程学期进行筛选。
		// <option value="0">无筛选</option>
		// <option value="1">秋冬</option>
		// <option value="2">秋</option>
		// <option value="3">冬</option>
		// <option value="5">春夏</option>
		// <option value="6">春</option>
		// <option value="7">夏</option>    
		"adjustments": [
			{
				"term": "0",
				"name": "国庆节",
				"fromStart": "2015-10-03T00:00+08:00",
				// 左闭右开,10-3~4 => 10-6~7。
				"fromEnd": "2015-10-05T00:00+08:00",
				"toStart": "2015-10-06T00:00+08:00",
				"toEnd": "2015-10-08T00:00+08:00"
			},
			{
				"term": "3",
				"name": "仅补冬单学期课程,",
				"fromStart": "2017-11-24T00:00+08:00",
				"fromEnd": "2017-11-25T00:00+08:00",
				"toStart": "2017-11-20T00:00+08:00",
				"toEnd": "2017-11-21T00:00+08:00"
			}
			// ...
		],
		// 下面是形策调课或其他特殊课程调课有关内容
		"special": [
			{
				"code": "371E0010",
				// 课程编号
				"weekly": "odd",
				// 课程周期 all:每周,odd:单周,even:双周
				"date": "2016-09-12T00:00+08:00"
			},
			{
				”code": "371E0010",
				"weekly": "even",
				"date": "2016-09-12T00:00+08:00"
			}
		]
	}
}

school-cal's People

Contributors

hexilee avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.