├── .eslintignore ├── .babelrc ├── .gitignore ├── .travis.yml ├── docs ├── fonts │ ├── Montserrat │ │ ├── Montserrat-Bold.eot │ │ ├── Montserrat-Bold.ttf │ │ ├── Montserrat-Bold.woff │ │ ├── Montserrat-Bold.woff2 │ │ ├── Montserrat-Regular.eot │ │ ├── Montserrat-Regular.ttf │ │ ├── Montserrat-Regular.woff │ │ └── Montserrat-Regular.woff2 │ └── Source-Sans-Pro │ │ ├── sourcesanspro-light-webfont.eot │ │ ├── sourcesanspro-light-webfont.ttf │ │ ├── sourcesanspro-light-webfont.woff │ │ ├── sourcesanspro-light-webfont.woff2 │ │ ├── sourcesanspro-regular-webfont.eot │ │ ├── sourcesanspro-regular-webfont.ttf │ │ ├── sourcesanspro-regular-webfont.woff │ │ └── sourcesanspro-regular-webfont.woff2 ├── scripts │ ├── polyfill.js │ ├── nav.js │ ├── linenumber.js │ ├── prettify │ │ ├── lang-css.js │ │ ├── Apache-License-2.0.txt │ │ └── prettify.js │ ├── commonNav.js │ ├── collapse.js │ └── search.js ├── styles │ ├── prettify.css │ └── jsdoc.css ├── days.js.html ├── book.js.html ├── index.js.html ├── index.html ├── ChineseHolidays.html ├── Days.html ├── global.html └── Book.html ├── test ├── bundled.js ├── cache.js ├── index.js └── book.js ├── .eslintrc.js ├── CHANGELOG.md ├── .github └── workflows │ └── node.js.yml ├── src ├── bundled.js ├── days.js ├── book.js ├── index.js └── cache.js ├── LICENSE ├── data ├── 2025.json ├── 2017.json ├── 2023.json ├── 2018.json ├── 2022.json ├── 2016.json ├── 2020.json ├── 2026.json ├── 2019.json ├── 2021.json └── 2024.json ├── package.json └── README.md /.eslintignore: -------------------------------------------------------------------------------- 1 | lib/*.js -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["@babel/preset-env"] 3 | } 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /cache 3 | /cache_temp 4 | /lib 5 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "16.13.0" 4 | - "14.18.1" 5 | - "12.22.7" 6 | -------------------------------------------------------------------------------- /docs/fonts/Montserrat/Montserrat-Bold.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bastengao/chinese-holidays-node/HEAD/docs/fonts/Montserrat/Montserrat-Bold.eot -------------------------------------------------------------------------------- /docs/fonts/Montserrat/Montserrat-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bastengao/chinese-holidays-node/HEAD/docs/fonts/Montserrat/Montserrat-Bold.ttf -------------------------------------------------------------------------------- /docs/fonts/Montserrat/Montserrat-Bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bastengao/chinese-holidays-node/HEAD/docs/fonts/Montserrat/Montserrat-Bold.woff -------------------------------------------------------------------------------- /docs/fonts/Montserrat/Montserrat-Bold.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bastengao/chinese-holidays-node/HEAD/docs/fonts/Montserrat/Montserrat-Bold.woff2 -------------------------------------------------------------------------------- /docs/fonts/Montserrat/Montserrat-Regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bastengao/chinese-holidays-node/HEAD/docs/fonts/Montserrat/Montserrat-Regular.eot -------------------------------------------------------------------------------- /docs/fonts/Montserrat/Montserrat-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bastengao/chinese-holidays-node/HEAD/docs/fonts/Montserrat/Montserrat-Regular.ttf -------------------------------------------------------------------------------- /docs/fonts/Montserrat/Montserrat-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bastengao/chinese-holidays-node/HEAD/docs/fonts/Montserrat/Montserrat-Regular.woff -------------------------------------------------------------------------------- /docs/fonts/Montserrat/Montserrat-Regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bastengao/chinese-holidays-node/HEAD/docs/fonts/Montserrat/Montserrat-Regular.woff2 -------------------------------------------------------------------------------- /docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bastengao/chinese-holidays-node/HEAD/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot -------------------------------------------------------------------------------- /docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bastengao/chinese-holidays-node/HEAD/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf -------------------------------------------------------------------------------- /docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bastengao/chinese-holidays-node/HEAD/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff -------------------------------------------------------------------------------- /docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bastengao/chinese-holidays-node/HEAD/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 -------------------------------------------------------------------------------- /docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bastengao/chinese-holidays-node/HEAD/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot -------------------------------------------------------------------------------- /docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bastengao/chinese-holidays-node/HEAD/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf -------------------------------------------------------------------------------- /docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bastengao/chinese-holidays-node/HEAD/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff -------------------------------------------------------------------------------- /docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bastengao/chinese-holidays-node/HEAD/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 -------------------------------------------------------------------------------- /docs/scripts/polyfill.js: -------------------------------------------------------------------------------- 1 | //IE Fix, src: https://www.reddit.com/r/programminghorror/comments/6abmcr/nodelist_lacks_foreach_in_internet_explorer/ 2 | if (typeof(NodeList.prototype.forEach)!==typeof(alert)){ 3 | NodeList.prototype.forEach=Array.prototype.forEach; 4 | } -------------------------------------------------------------------------------- /test/bundled.js: -------------------------------------------------------------------------------- 1 | const should = require('should'); 2 | const Bundled = require('../lib/bundled'); 3 | 4 | describe('Bundled', () => { 5 | it('loadEvents', () => { 6 | should.equal(Bundled.loadEvents().length, 137); 7 | 8 | const days = Bundled.loadEvents()[0].days(); 9 | should.equal(days.length, 3); 10 | should(days[0]).be.a.Date(); 11 | }); 12 | }); 13 | -------------------------------------------------------------------------------- /docs/scripts/nav.js: -------------------------------------------------------------------------------- 1 | function scrollToNavItem() { 2 | var path = window.location.href.split('/').pop().replace(/\.html/, ''); 3 | document.querySelectorAll('nav a').forEach(function(link) { 4 | var href = link.attributes.href.value.replace(/\.html/, ''); 5 | if (path === href) { 6 | link.scrollIntoView({block: 'center'}); 7 | return; 8 | } 9 | }) 10 | } 11 | 12 | scrollToNavItem(); 13 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | "env": { 3 | "es6": true, 4 | "node": true, 5 | "mocha": true 6 | }, 7 | "extends": "airbnb-base", 8 | "globals": { 9 | "Atomics": "readonly", 10 | "SharedArrayBuffer": "readonly" 11 | }, 12 | "parserOptions": { 13 | "ecmaVersion": 2018, 14 | "sourceType": "module" 15 | }, 16 | "rules": { 17 | "semi": ["warn", "always"] 18 | } 19 | }; 20 | -------------------------------------------------------------------------------- /test/cache.js: -------------------------------------------------------------------------------- 1 | const Cache = require('../lib/cache'); 2 | const Days = require('../lib/days'); 3 | 4 | describe('Cache', () => { 5 | it('loadEvents', () => Cache.loadEventsFromRemote().should.be.fulfilled()); 6 | 7 | it('loadEventsFromRemote', (done) => { 8 | Cache.loadEventsFromRemote().then((events) => { 9 | events.should.not.be.null(); 10 | events[0].should.instanceOf(Days); 11 | done(); 12 | }).catch((err) => console.log(err)); 13 | }); 14 | 15 | // TODO: more test 16 | }); 17 | -------------------------------------------------------------------------------- /docs/scripts/linenumber.js: -------------------------------------------------------------------------------- 1 | /*global document */ 2 | (function() { 3 | var source = document.getElementsByClassName('prettyprint source linenums'); 4 | var i = 0; 5 | var lineNumber = 0; 6 | var lineId; 7 | var lines; 8 | var totalLines; 9 | var anchorHash; 10 | 11 | if (source && source[0]) { 12 | anchorHash = document.location.hash.substring(1); 13 | lines = source[0].getElementsByTagName('li'); 14 | totalLines = lines.length; 15 | 16 | for (; i < totalLines; i++) { 17 | lineNumber++; 18 | lineId = 'line' + lineNumber; 19 | lines[i].id = lineId; 20 | if (lineId === anchorHash) { 21 | lines[i].className += ' selected'; 22 | } 23 | } 24 | } 25 | })(); 26 | -------------------------------------------------------------------------------- /docs/scripts/prettify/lang-css.js: -------------------------------------------------------------------------------- 1 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\f\r ]+/,null," \t\r\n "]],[["str",/^"(?:[^\n\f\r"\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*"/,null],["str",/^'(?:[^\n\f\r'\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*'/,null],["lang-css-str",/^url\(([^"')]*)\)/i],["kwd",/^(?:url|rgb|!important|@import|@page|@media|@charset|inherit)(?=[^\w-]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*)\s*:/i],["com",/^\/\*[^*]*\*+(?:[^*/][^*]*\*+)*\//],["com", 2 | /^(?:<\!--|--\>)/],["lit",/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],["lit",/^#[\da-f]{3,6}/i],["pln",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i],["pun",/^[^\s\w"']+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[["kwd",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[["str",/^[^"')]+/]]),["css-str"]); 3 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # v1.8.0 2 | 3 | Support year 2026 offline data. 4 | 5 | # v1.7.0 6 | 7 | Support year 2025 offline data. 8 | 9 | # v1.6.0 10 | 11 | Support year 2024 offline data. 12 | 13 | # v1.5.0 14 | 15 | Support year 2023 offline data. 16 | 17 | # v1.4.1 18 | 19 | Fix 2022 spring festival. 20 | 21 | # v1.4.0 22 | 23 | Support year 2022 offline data. 24 | 25 | # v1.3.0 26 | 27 | Support year 2021 offline data. 28 | 29 | # v1.2.1 30 | 31 | Change to new data endpoint. Previous data endpoint is no longer available. 32 | 33 | # v1.2.0 34 | 35 | Support year 2020 offline data. 36 | 37 | # v1.1.0 38 | 39 | Change source to ES2015 syntax. 40 | 41 | # v1.0.1 42 | 43 | Fix npm pacakge files 44 | 45 | # v1.0.0 46 | 47 | Support online update data and cache offline data. 48 | 49 | # v0.4.1 50 | 51 | Update year 2019 5.1 dates. 52 | 53 | # v0.4.0 54 | 55 | Support year 2019 offline data. 56 | -------------------------------------------------------------------------------- /.github/workflows/node.js.yml: -------------------------------------------------------------------------------- 1 | # This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions 3 | 4 | name: Node.js CI 5 | 6 | on: 7 | push: 8 | branches: [ master ] 9 | pull_request: 10 | branches: [ master ] 11 | 12 | jobs: 13 | build: 14 | 15 | runs-on: ubuntu-latest 16 | 17 | strategy: 18 | matrix: 19 | node-version: [14.x, 16.x, 18.x] 20 | # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ 21 | 22 | steps: 23 | - uses: actions/checkout@v2 24 | - name: Use Node.js ${{ matrix.node-version }} 25 | uses: actions/setup-node@v2 26 | with: 27 | node-version: ${{ matrix.node-version }} 28 | cache: 'npm' 29 | - run: npm ci 30 | - run: npm run build --if-present 31 | - run: npm test 32 | -------------------------------------------------------------------------------- /src/bundled.js: -------------------------------------------------------------------------------- 1 | import fs from 'fs'; 2 | import path from 'path'; 3 | import Days from './days'; 4 | 5 | const loadEventsFromDir = function loadEventsFromDir(dir) { 6 | let files = fs.readdirSync(dir); 7 | files = files.filter((file) => file !== 'index.json'); 8 | const eventsOfYears = files.map((file) => { 9 | const elements = JSON.parse(fs.readFileSync(path.resolve(dir, file), 'utf8')); 10 | return elements.map((ele) => new Days(ele.name, ele.range, ele.type)); 11 | }); 12 | 13 | let events = []; 14 | eventsOfYears.forEach((eventsOfYear) => { 15 | events = events.concat(eventsOfYear); 16 | }); 17 | 18 | return events; 19 | }; 20 | 21 | const loadEvents = function loadEvents() { 22 | const dataDirectory = path.resolve(__dirname, '../data'); 23 | return loadEventsFromDir(dataDirectory); 24 | }; 25 | 26 | const Bundled = { 27 | events() { 28 | if (!this.eventsData) { 29 | this.eventsData = loadEvents(); 30 | } 31 | return this.eventsData; 32 | }, 33 | 34 | loadEventsFromDir, 35 | loadEvents, 36 | }; 37 | 38 | module.exports = Bundled; 39 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Basten Gao 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /docs/scripts/commonNav.js: -------------------------------------------------------------------------------- 1 | if (typeof fetch === 'function') { 2 | const init = () => { 3 | if (typeof scrollToNavItem !== 'function') return false 4 | scrollToNavItem() 5 | // hideAllButCurrent not always loaded 6 | if (typeof hideAllButCurrent === 'function') hideAllButCurrent() 7 | return true 8 | } 9 | fetch('./nav.inc.html') 10 | .then(response => response.ok ? response.text() : `${response.url} => ${response.status} ${response.statusText}`) 11 | .then(body => { 12 | document.querySelector('nav').innerHTML += body 13 | // nav.js should be quicker to load than nav.inc.html, a fallback just in case 14 | return init() 15 | }) 16 | .then(done => { 17 | if (done) return 18 | let i = 0 19 | ;(function waitUntilNavJs () { 20 | if (init()) return 21 | if (i++ < 100) return setTimeout(waitUntilNavJs, 300) 22 | console.error(Error('nav.js not loaded after 30s waiting for it')) 23 | })() 24 | }) 25 | .catch(error => console.error(error)) 26 | } else { 27 | console.error(Error('Browser too old to display commonNav (remove commonNav docdash option)')) 28 | } 29 | -------------------------------------------------------------------------------- /data/2025.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "元旦", 4 | "range": ["2025-01-01"], 5 | "type": "holiday" 6 | }, 7 | { 8 | "name": "春节", 9 | "range": ["2025-01-26"], 10 | "type": "workingday" 11 | }, 12 | { 13 | "name": "春节", 14 | "range": ["2025-01-28", "2025-02-04"], 15 | "type": "holiday" 16 | }, 17 | { 18 | "name": "春节", 19 | "range": ["2025-02-08"], 20 | "type": "workingday" 21 | }, 22 | { 23 | "name": "清明节", 24 | "range": ["2025-04-04", "2025-04-06"], 25 | "type": "holiday" 26 | }, 27 | { 28 | "name": "劳动节", 29 | "range": ["2025-04-27"], 30 | "type": "workingday" 31 | }, 32 | { 33 | "name": "劳动节", 34 | "range": ["2025-05-01", "2025-05-05"], 35 | "type": "holiday" 36 | }, 37 | { 38 | "name": "端午节", 39 | "range": ["2025-05-31", "2025-06-02"], 40 | "type": "holiday" 41 | }, 42 | { 43 | "name": "国庆节、中秋节", 44 | "range": ["2025-09-28"], 45 | "type": "workingday" 46 | }, 47 | { 48 | "name": "国庆节、中秋节", 49 | "range": ["2025-10-01", "2025-10-08"], 50 | "type": "holiday" 51 | }, 52 | { 53 | "name": "国庆节、中秋节", 54 | "range": ["2025-10-11"], 55 | "type": "workingday" 56 | } 57 | ] 58 | -------------------------------------------------------------------------------- /data/2017.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "元旦", 4 | "range": ["2016-12-31", "2017-01-02"], 5 | "type": "holiday" 6 | }, 7 | { 8 | "name": "春节", 9 | "range": ["2017-01-22"], 10 | "type": "workingday" 11 | }, 12 | { 13 | "name": "春节", 14 | "range": ["2017-01-27", "2017-02-02"], 15 | "type": "holiday" 16 | }, 17 | { 18 | "name": "春节", 19 | "range": ["2017-02-04"], 20 | "type": "workingday" 21 | }, 22 | { 23 | "name": "清明节", 24 | "range": ["2017-04-01"], 25 | "type": "workingday" 26 | }, 27 | { 28 | "name": "清明节", 29 | "range": ["2017-04-02", "2017-04-04"], 30 | "type": "holiday" 31 | }, 32 | { 33 | "name": "劳动节", 34 | "range": ["2017-04-29", "2017-05-01"], 35 | "type": "holiday" 36 | }, 37 | { 38 | "name": "端午节", 39 | "range": ["2017-05-27"], 40 | "type": "workingday" 41 | }, 42 | { 43 | "name": "端午节", 44 | "range": ["2017-05-28", "2017-05-30"], 45 | "type": "holiday" 46 | }, 47 | { 48 | "name": "国庆节", 49 | "range": ["2017-09-30"], 50 | "type": "workingday" 51 | }, 52 | { 53 | "name": "国庆节、中秋节", 54 | "range": ["2017-10-01", "2017-10-08"], 55 | "type": "holiday" 56 | } 57 | ] 58 | -------------------------------------------------------------------------------- /docs/styles/prettify.css: -------------------------------------------------------------------------------- 1 | .pln { 2 | color: #ddd; 3 | } 4 | 5 | /* string content */ 6 | .str { 7 | color: #61ce3c; 8 | } 9 | 10 | /* a keyword */ 11 | .kwd { 12 | color: #fbde2d; 13 | } 14 | 15 | /* a comment */ 16 | .com { 17 | color: #aeaeae; 18 | } 19 | 20 | /* a type name */ 21 | .typ { 22 | color: #8da6ce; 23 | } 24 | 25 | /* a literal value */ 26 | .lit { 27 | color: #fbde2d; 28 | } 29 | 30 | /* punctuation */ 31 | .pun { 32 | color: #ddd; 33 | } 34 | 35 | /* lisp open bracket */ 36 | .opn { 37 | color: #000000; 38 | } 39 | 40 | /* lisp close bracket */ 41 | .clo { 42 | color: #000000; 43 | } 44 | 45 | /* a markup tag name */ 46 | .tag { 47 | color: #8da6ce; 48 | } 49 | 50 | /* a markup attribute name */ 51 | .atn { 52 | color: #fbde2d; 53 | } 54 | 55 | /* a markup attribute value */ 56 | .atv { 57 | color: #ddd; 58 | } 59 | 60 | /* a declaration */ 61 | .dec { 62 | color: #EF5050; 63 | } 64 | 65 | /* a variable name */ 66 | .var { 67 | color: #c82829; 68 | } 69 | 70 | /* a function name */ 71 | .fun { 72 | color: #4271ae; 73 | } 74 | 75 | /* Specify class=linenums on a pre to get line numbering */ 76 | ol.linenums { 77 | margin-top: 0; 78 | margin-bottom: 0; 79 | padding-bottom: 2px; 80 | } 81 | -------------------------------------------------------------------------------- /data/2023.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "元旦", 4 | "range": ["2022-12-31", "2023-01-02"], 5 | "type": "holiday" 6 | }, 7 | { 8 | "name": "春节", 9 | "range": ["2023-01-21", "2023-01-27"], 10 | "type": "holiday" 11 | }, 12 | { 13 | "name": "春节", 14 | "range": ["2023-01-28", "2023-01-29"], 15 | "type": "workingday" 16 | }, 17 | { 18 | "name": "清明节", 19 | "range": ["2023-04-05"], 20 | "type": "holiday" 21 | }, 22 | { 23 | "name": "劳动节", 24 | "range": ["2023-04-23"], 25 | "type": "workingday" 26 | }, 27 | { 28 | "name": "劳动节", 29 | "range": ["2023-04-29", "2023-05-03"], 30 | "type": "holiday" 31 | }, 32 | { 33 | "name": "劳动节", 34 | "range": ["2023-05-06"], 35 | "type": "workingday" 36 | }, 37 | { 38 | "name": "端午节", 39 | "range": ["2023-06-22", "2023-06-24"], 40 | "type": "holiday" 41 | }, 42 | { 43 | "name": "端午节", 44 | "range": ["2023-06-25"], 45 | "type": "workingday" 46 | }, 47 | { 48 | "name": "中秋节/国庆节", 49 | "range": ["2023-09-29", "2023-10-06"], 50 | "type": "holiday" 51 | }, 52 | { 53 | "name": "中秋节/国庆节", 54 | "range": ["2023-10-07", "2023-10-08"], 55 | "type": "workingday" 56 | } 57 | ] 58 | -------------------------------------------------------------------------------- /test/index.js: -------------------------------------------------------------------------------- 1 | const should = require('should'); 2 | const ChineseHolidays = require('../lib'); 3 | 4 | describe('ChineseHolidays', () => { 5 | it('ready', () => { 6 | ChineseHolidays.ready((book) => { 7 | (book).should.not.be.null(); 8 | }); 9 | 10 | ChineseHolidays.ready().then((book) => { 11 | (book).should.not.be.null(); 12 | }); 13 | }); 14 | 15 | it('ready-offline', () => { 16 | ChineseHolidays.ready({ offline: true }).then((book) => { 17 | (book).should.not.be.null(); 18 | }); 19 | }); 20 | 21 | it('all', () => { 22 | ChineseHolidays.ready((book) => { 23 | book.all(); 24 | }); 25 | }); 26 | 27 | it('isHoliday', () => { 28 | ChineseHolidays.ready((book) => { 29 | should.equal(book.isHoliday(new Date(2016, 0, 1)), true); 30 | should.equal(book.isHoliday(new Date(2016, 0, 5)), false); 31 | }); 32 | }); 33 | 34 | it('isWorkingday', () => { 35 | ChineseHolidays.ready((book) => { 36 | should.equal(book.isWorkingday(new Date(2016, 0, 1)), false); 37 | should.equal(book.isWorkingday(new Date(2016, 0, 5)), true); 38 | }); 39 | }); 40 | 41 | it('events', () => { 42 | ChineseHolidays.ready((book) => { 43 | book.events(); 44 | }); 45 | }); 46 | }); 47 | -------------------------------------------------------------------------------- /data/2018.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "元旦", 4 | "range": ["2017-12-30", "2018-01-01"], 5 | "type": "holiday" 6 | }, 7 | { 8 | "name": "春节", 9 | "range": ["2018-02-11"], 10 | "type": "workingday" 11 | }, 12 | { 13 | "name": "春节", 14 | "range": ["2018-02-15", "2018-02-21"], 15 | "type": "holiday" 16 | }, 17 | { 18 | "name": "春节", 19 | "range": ["2018-02-24"], 20 | "type": "workingday" 21 | }, 22 | { 23 | "name": "清明节", 24 | "range": ["2018-04-05", "2018-04-07"], 25 | "type": "holiday" 26 | }, 27 | { 28 | "name": "清明节", 29 | "range": ["2018-04-08"], 30 | "type": "workingday" 31 | }, 32 | { 33 | "name": "劳动节", 34 | "range": ["2018-04-28"], 35 | "type": "workingday" 36 | }, 37 | { 38 | "name": "劳动节", 39 | "range": ["2018-04-29", "2018-05-01"], 40 | "type": "holiday" 41 | }, 42 | { 43 | "name": "端午节", 44 | "range": ["2018-06-16", "2018-06-18"], 45 | "type": "holiday" 46 | }, 47 | { 48 | "name": "中秋节", 49 | "range": ["2018-09-22", "2018-09-24"], 50 | "type": "holiday" 51 | }, 52 | { 53 | "name": "国庆节", 54 | "range": ["2018-09-29","2018-09-30"], 55 | "type": "workingday" 56 | }, 57 | { 58 | "name": "国庆节", 59 | "range": ["2018-10-01", "2018-10-07"], 60 | "type": "holiday" 61 | } 62 | ] 63 | 64 | -------------------------------------------------------------------------------- /data/2022.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "元旦", 4 | "range": ["2022-01-01", "2022-01-03"], 5 | "type": "holiday" 6 | }, 7 | { 8 | "name": "春节", 9 | "range": ["2022-01-29", "2022-01-30"], 10 | "type": "workingday" 11 | }, 12 | { 13 | "name": "春节", 14 | "range": ["2022-01-31", "2022-02-06"], 15 | "type": "holiday" 16 | }, 17 | { 18 | "name": "清明节", 19 | "range": ["2022-04-02"], 20 | "type": "workingday" 21 | }, 22 | { 23 | "name": "清明节", 24 | "range": ["2022-04-03", "2022-04-05"], 25 | "type": "holiday" 26 | }, 27 | { 28 | "name": "劳动节", 29 | "range": ["2022-04-24"], 30 | "type": "workingday" 31 | }, 32 | { 33 | "name": "劳动节", 34 | "range": ["2022-04-30", "2022-05-04"], 35 | "type": "holiday" 36 | }, 37 | { 38 | "name": "劳动节", 39 | "range": ["2022-05-07"], 40 | "type": "workingday" 41 | }, 42 | { 43 | "name": "端午节", 44 | "range": ["2022-06-03", "2022-06-05"], 45 | "type": "holiday" 46 | }, 47 | { 48 | "name": "中秋节", 49 | "range": ["2022-09-10", "2022-09-12"], 50 | "type": "holiday" 51 | }, 52 | { 53 | "name": "国庆节", 54 | "range": ["2022-10-01", "2022-10-07"], 55 | "type": "holiday" 56 | }, 57 | { 58 | "name": "国庆节", 59 | "range": ["2022-10-08", "2022-10-09"], 60 | "type": "workingday" 61 | } 62 | ] 63 | -------------------------------------------------------------------------------- /data/2016.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "元旦", 4 | "range": ["2016-01-01", "2016-01-03"], 5 | "type": "holiday" 6 | }, 7 | 8 | { 9 | "name": "春节", 10 | "range": ["2016-02-06"], 11 | "type": "workingday" 12 | }, 13 | { 14 | "name": "春节", 15 | "range": ["2016-02-07", "2016-02-13"], 16 | "type": "holiday" 17 | }, 18 | { 19 | "name": "春节", 20 | "range": ["2016-02-14"], 21 | "type": "workingday" 22 | }, 23 | 24 | { 25 | "name": "清明节", 26 | "range": ["2016-04-02", "2016-04-04"], 27 | "type": "holiday" 28 | }, 29 | 30 | { 31 | "name": "劳动节", 32 | "range": ["2016-04-30", "2016-05-02"], 33 | "type": "holiday" 34 | }, 35 | 36 | 37 | { 38 | "name": "端午节", 39 | "range": ["2016-06-09", "2016-06-11"], 40 | "type": "holiday" 41 | }, 42 | { 43 | "name": "端午节", 44 | "range": ["2016-06-12"], 45 | "type": "workingday" 46 | }, 47 | 48 | { 49 | "name": "中秋节", 50 | "range": ["2016-09-15", "2016-09-17"], 51 | "type": "holiday" 52 | }, 53 | { 54 | "name": "中秋节", 55 | "range": ["2016-09-18"], 56 | "type": "workingday" 57 | }, 58 | 59 | { 60 | "name": "国庆节", 61 | "range": ["2016-10-01", "2016-10-07"], 62 | "type": "holiday" 63 | }, 64 | { 65 | "name": "国庆节", 66 | "range": ["2016-10-08", "2016-10-09"], 67 | "type": "workingday" 68 | } 69 | ] 70 | -------------------------------------------------------------------------------- /data/2020.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "元旦", 4 | "range": ["2020-01-01"], 5 | "type": "holiday" 6 | }, 7 | { 8 | "name": "春节", 9 | "range": ["2020-01-19"], 10 | "type": "workingday" 11 | }, 12 | { 13 | "name": "春节", 14 | "range": ["2020-01-24", "2020-01-30"], 15 | "type": "holiday" 16 | }, 17 | { 18 | "name": "春节", 19 | "range": ["2020-02-01"], 20 | "type": "workingday" 21 | }, 22 | { 23 | "name": "清明节", 24 | "range": ["2020-04-04", "2020-04-06"], 25 | "type": "holiday" 26 | }, 27 | { 28 | "name": "劳动节", 29 | "range": ["2020-04-26"], 30 | "type": "workingday" 31 | }, 32 | { 33 | "name": "劳动节", 34 | "range": ["2020-05-01", "2020-05-05"], 35 | "type": "holiday" 36 | }, 37 | { 38 | "name": "劳动节", 39 | "range": ["2020-05-09"], 40 | "type": "workingday" 41 | }, 42 | { 43 | "name": "端午节", 44 | "range": ["2020-06-25", "2020-06-27"], 45 | "type": "holiday" 46 | }, 47 | { 48 | "name": "端午节", 49 | "range": ["2020-06-28"], 50 | "type": "workingday" 51 | }, 52 | { 53 | "name": "中秋节/国庆节", 54 | "range": ["2020-09-27"], 55 | "type": "workingday" 56 | }, 57 | { 58 | "name": "中秋节/国庆节", 59 | "range": ["2020-10-01", "2020-10-08"], 60 | "type": "holiday" 61 | }, 62 | { 63 | "name": "中秋节/国庆节", 64 | "range": ["2020-10-10"], 65 | "type": "workingday" 66 | } 67 | ] 68 | -------------------------------------------------------------------------------- /data/2026.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "元旦", 4 | "range": ["2026-01-01", "2026-01-03"], 5 | "type": "holiday" 6 | }, 7 | { 8 | "name": "元旦", 9 | "range": ["2026-01-04"], 10 | "type": "workingday" 11 | }, 12 | { 13 | "name": "春节", 14 | "range": ["2026-02-14"], 15 | "type": "workingday" 16 | }, 17 | { 18 | "name": "春节", 19 | "range": ["2026-02-15", "2026-02-23"], 20 | "type": "holiday" 21 | }, 22 | { 23 | "name": "春节", 24 | "range": ["2026-02-28"], 25 | "type": "workingday" 26 | }, 27 | { 28 | "name": "清明节", 29 | "range": ["2026-04-04", "2026-04-06"], 30 | "type": "holiday" 31 | }, 32 | { 33 | "name": "劳动节", 34 | "range": ["2026-05-01", "2026-05-05"], 35 | "type": "holiday" 36 | }, 37 | { 38 | "name": "劳动节", 39 | "range": ["2026-05-09"], 40 | "type": "workingday" 41 | }, 42 | { 43 | "name": "端午节", 44 | "range": ["2026-06-19", "2026-06-21"], 45 | "type": "holiday" 46 | }, 47 | { 48 | "name": "中秋节", 49 | "range": ["2026-09-25", "2026-09-27"], 50 | "type": "holiday" 51 | }, 52 | { 53 | "name": "国庆节", 54 | "range": ["2026-09-20"], 55 | "type": "workingday" 56 | }, 57 | { 58 | "name": "国庆节", 59 | "range": ["2026-10-01", "2026-10-07"], 60 | "type": "holiday" 61 | }, 62 | { 63 | "name": "国庆节", 64 | "range": ["2026-10-10"], 65 | "type": "workingday" 66 | } 67 | ] 68 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "chinese-holidays", 3 | "version": "1.8.0", 4 | "description": "Chinese holidays", 5 | "main": "lib/index.js", 6 | "files": [ 7 | "lib", 8 | "data" 9 | ], 10 | "scripts": { 11 | "build": "npx babel src -d lib", 12 | "test": "npm run build && mocha --timeout 10000", 13 | "generate-docs": "jsdoc src -r -R README.md -t node_modules/docdash -d ./docs/" 14 | }, 15 | "repository": { 16 | "type": "git", 17 | "url": "git+ssh://git@github.com/bastengao/chinese-holidays-node.git" 18 | }, 19 | "keywords": [ 20 | "chinese", 21 | "holidays" 22 | ], 23 | "author": "Basten Gao (http://bastengao.com)", 24 | "license": "MIT", 25 | "bugs": { 26 | "url": "https://github.com/bastengao/chinese-holidays-node/issues" 27 | }, 28 | "homepage": "https://github.com/bastengao/chinese-holidays-node#readme", 29 | "devDependencies": { 30 | "@babel/cli": "^7.6.4", 31 | "@babel/core": "^7.6.4", 32 | "@babel/preset-env": "^7.6.3", 33 | "@babel/register": "^7.6.2", 34 | "docdash": "^2.0.0", 35 | "eslint": "^6.1.0", 36 | "eslint-config-airbnb-base": "^14.0.0", 37 | "eslint-plugin-import": "^2.18.2", 38 | "mocha": "^10.1.0", 39 | "should": "^9.0.2" 40 | }, 41 | "dependencies": { 42 | "lodash": "^4.17.13", 43 | "moment": "^2.19.3", 44 | "request": "^2.88.0", 45 | "request-promise-native": "^1.0.5" 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /data/2019.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "元旦", 4 | "range": ["2018-12-29"], 5 | "type": "workingday" 6 | }, 7 | { 8 | "name": "元旦", 9 | "range": ["2018-12-30", "2019-01-01"], 10 | "type": "holiday" 11 | }, 12 | { 13 | "name": "春节", 14 | "range": ["2019-02-02", "2019-02-03"], 15 | "type": "workingday" 16 | }, 17 | { 18 | "name": "春节", 19 | "range": ["2019-02-04", "2019-02-10"], 20 | "type": "holiday" 21 | }, 22 | { 23 | "name": "清明节", 24 | "range": ["2019-04-05", "2019-04-07"], 25 | "type": "holiday" 26 | }, 27 | { 28 | "name": "劳动节", 29 | "range": ["2019-04-28"], 30 | "type": "workingday" 31 | }, 32 | { 33 | "name": "劳动节", 34 | "range": ["2019-05-01", "2019-05-04"], 35 | "type": "holiday" 36 | }, 37 | { 38 | "name": "劳动节", 39 | "range": ["2019-05-05"], 40 | "type": "workingday" 41 | }, 42 | { 43 | "name": "端午节", 44 | "range": ["2019-06-07", "2019-06-09"], 45 | "type": "holiday" 46 | }, 47 | { 48 | "name": "中秋节", 49 | "range": ["2019-09-13", "2019-09-15"], 50 | "type": "holiday" 51 | }, 52 | { 53 | "name": "国庆节", 54 | "range": ["2019-09-29"], 55 | "type": "workingday" 56 | }, 57 | { 58 | "name": "国庆节", 59 | "range": ["2019-10-01", "2019-10-07"], 60 | "type": "holiday" 61 | }, 62 | { 63 | "name": "国庆节", 64 | "range": ["2019-10-12"], 65 | "type": "workingday" 66 | } 67 | ] 68 | -------------------------------------------------------------------------------- /src/days.js: -------------------------------------------------------------------------------- 1 | import moment from 'moment'; 2 | 3 | const rangeToDates = function rangeToDates(startDate, endDate) { 4 | const dates = [startDate.toDate()]; 5 | const start = startDate.toDate(); 6 | for (let i = 1; i < 100; i += 1) { 7 | const date = moment(start).add(i, 'days'); 8 | if (date.isSame(endDate, 'day')) { 9 | dates.push(date.toDate()); 10 | break; 11 | } else { 12 | dates.push(date.toDate()); 13 | } 14 | } 15 | 16 | return dates; 17 | }; 18 | 19 | 20 | /** 21 | * @class Days 22 | * @hideconstructor 23 | */ 24 | class Days { 25 | constructor(name, range, type) { 26 | this.name = name; 27 | this.range = range; 28 | this.type = type; 29 | } 30 | 31 | /** 32 | * return if is holiday 33 | * @returns {boolean} 34 | */ 35 | isHoliday() { 36 | return this.type === 'holiday'; 37 | } 38 | 39 | /** 40 | * return if is workingday 41 | * @returns {boolean} 42 | */ 43 | isWorkingday() { 44 | return this.type === 'workingday'; 45 | } 46 | 47 | /** 48 | * return days 49 | * @returns {Array} days 50 | */ 51 | days() { 52 | let startDate = null; 53 | startDate = moment(this.range[0]); 54 | if (this.range.length === 1) { 55 | return [startDate.toDate()]; 56 | } 57 | if (this.range.length === 2) { 58 | const endDate = moment(this.range[1]); 59 | return rangeToDates(startDate, endDate); 60 | } 61 | 62 | // TODO: handel exception 63 | return []; 64 | } 65 | } 66 | 67 | module.exports = Days; 68 | -------------------------------------------------------------------------------- /data/2021.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "元旦", 4 | "range": ["2021-01-01", "2021-01-03"], 5 | "type": "holiday" 6 | }, 7 | { 8 | "name": "春节", 9 | "range": ["2021-02-07"], 10 | "type": "workingday" 11 | }, 12 | { 13 | "name": "春节", 14 | "range": ["2021-02-11", "2021-02-17"], 15 | "type": "holiday" 16 | }, 17 | { 18 | "name": "春节", 19 | "range": ["2021-02-20"], 20 | "type": "workingday" 21 | }, 22 | { 23 | "name": "清明节", 24 | "range": ["2021-04-03", "2021-04-05"], 25 | "type": "holiday" 26 | }, 27 | { 28 | "name": "劳动节", 29 | "range": ["2021-04-25"], 30 | "type": "workingday" 31 | }, 32 | { 33 | "name": "劳动节", 34 | "range": ["2021-05-01", "2021-05-05"], 35 | "type": "holiday" 36 | }, 37 | { 38 | "name": "劳动节", 39 | "range": ["2021-05-08"], 40 | "type": "workingday" 41 | }, 42 | { 43 | "name": "端午节", 44 | "range": ["2021-06-12", "2021-06-14"], 45 | "type": "holiday" 46 | }, 47 | { 48 | "name": "中秋节", 49 | "range": ["2021-09-18"], 50 | "type": "workingday" 51 | }, 52 | { 53 | "name": "中秋节", 54 | "range": ["2021-09-19", "2021-09-21"], 55 | "type": "holiday" 56 | }, 57 | { 58 | "name": "国庆节", 59 | "range": ["2021-09-26"], 60 | "type": "workingday" 61 | }, 62 | { 63 | "name": "国庆节", 64 | "range": ["2021-10-01", "2021-10-07"], 65 | "type": "holiday" 66 | }, 67 | { 68 | "name": "国庆节", 69 | "range": ["2021-10-09"], 70 | "type": "workingday" 71 | } 72 | ] 73 | -------------------------------------------------------------------------------- /data/2024.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "元旦", 4 | "range": ["2023-12-30", "2024-01-01"], 5 | "type": "holiday" 6 | }, 7 | { 8 | "name": "春节", 9 | "range": ["2024-02-04"], 10 | "type": "workingday" 11 | }, 12 | { 13 | "name": "春节", 14 | "range": ["2024-02-10", "2024-02-17"], 15 | "type": "holiday" 16 | }, 17 | { 18 | "name": "春节", 19 | "range": ["2024-02-18"], 20 | "type": "workingday" 21 | }, 22 | { 23 | "name": "清明节", 24 | "range": ["2024-04-04", "2024-04-06"], 25 | "type": "holiday" 26 | }, 27 | { 28 | "name": "清明节", 29 | "range": ["2024-04-07"], 30 | "type": "workingday" 31 | }, 32 | { 33 | "name": "劳动节", 34 | "range": ["2024-04-28"], 35 | "type": "workingday" 36 | }, 37 | { 38 | "name": "劳动节", 39 | "range": ["2024-05-01", "2024-05-05"], 40 | "type": "holiday" 41 | }, 42 | { 43 | "name": "劳动节", 44 | "range": ["2024-05-11"], 45 | "type": "workingday" 46 | }, 47 | { 48 | "name": "端午节", 49 | "range": ["2024-06-08", "2024-06-10"], 50 | "type": "holiday" 51 | }, 52 | { 53 | "name": "中秋节", 54 | "range": ["2024-09-14"], 55 | "type": "workingday" 56 | }, 57 | { 58 | "name": "中秋节", 59 | "range": ["2024-09-15", "2024-09-17"], 60 | "type": "holiday" 61 | }, 62 | { 63 | "name": "国庆节", 64 | "range": ["2024-09-29"], 65 | "type": "workingday" 66 | }, 67 | { 68 | "name": "国庆节", 69 | "range": ["2024-10-01", "2024-10-07"], 70 | "type": "holiday" 71 | }, 72 | { 73 | "name": "国庆节", 74 | "range": ["2024-10-12"], 75 | "type": "workingday" 76 | } 77 | ] 78 | -------------------------------------------------------------------------------- /docs/scripts/collapse.js: -------------------------------------------------------------------------------- 1 | function hideAllButCurrent(){ 2 | //by default all submenut items are hidden 3 | //but we need to rehide them for search 4 | document.querySelectorAll("nav > ul").forEach(function(parent) { 5 | if (parent.className.indexOf("collapse_top") !== -1) { 6 | parent.style.display = "none"; 7 | } 8 | }); 9 | document.querySelectorAll("nav > ul > li > ul li").forEach(function(parent) { 10 | parent.style.display = "none"; 11 | }); 12 | document.querySelectorAll("nav > h3").forEach(function(section) { 13 | if (section.className.indexOf("collapsed_header") !== -1) { 14 | section.addEventListener("click", function(){ 15 | if (section.nextSibling.style.display === "none") { 16 | section.nextSibling.style.display = "block"; 17 | } else { 18 | section.nextSibling.style.display = "none"; 19 | } 20 | }); 21 | } 22 | }); 23 | 24 | //only current page (if it exists) should be opened 25 | var file = window.location.pathname.split("/").pop().replace(/\.html/, ''); 26 | document.querySelectorAll("nav > ul > li > a").forEach(function(parent) { 27 | var href = parent.attributes.href.value.replace(/\.html/, ''); 28 | if (file === href) { 29 | if (parent.parentNode.parentNode.className.indexOf("collapse_top") !== -1) { 30 | parent.parentNode.parentNode.style.display = "block"; 31 | } 32 | parent.parentNode.querySelectorAll("ul li").forEach(function(elem) { 33 | elem.style.display = "block"; 34 | }); 35 | } 36 | }); 37 | } 38 | 39 | hideAllButCurrent(); -------------------------------------------------------------------------------- /test/book.js: -------------------------------------------------------------------------------- 1 | const should = require('should'); 2 | 3 | const Days = require('../lib/days'); 4 | const Book = require('../lib/book'); 5 | 6 | const data = [ 7 | { name: '元旦', range: ['2018-12-29'], type: 'workingday' }, 8 | { name: '元旦', range: ['2018-12-30', '2019-01-01'], type: 'holiday' }, 9 | ]; 10 | const events = data.map((ele) => new Days(ele.name, ele.range, ele.type)); 11 | 12 | describe('books', () => { 13 | it('events', () => { 14 | const book = new Book(events); 15 | should.equal(book.events().length, 2); 16 | }); 17 | 18 | it('all', () => { 19 | const book = new Book(events); 20 | const all = book.all(); 21 | should.equal(all.length, 1); 22 | should.equal(all[0], events[1]); 23 | }); 24 | 25 | it('book', () => { 26 | const book = new Book(events); 27 | book.book().should.not.be.null(); 28 | }); 29 | 30 | it('event', () => { 31 | const book = new Book(events); 32 | let event = book.event('2018-12-29'); 33 | should.equal(event, events[0]); 34 | 35 | event = book.event('2019-01-01'); 36 | should.equal(event, events[1]); 37 | }); 38 | 39 | it('isWorkingday', () => { 40 | const book = new Book(events); 41 | should.equal(book.isWorkingday('2018-12-29'), true); 42 | should.equal(book.isWorkingday('2018-12-30'), false); 43 | }); 44 | 45 | it('isHoliday', () => { 46 | const book = new Book(events); 47 | should.equal(book.isHoliday('2018-12-29'), false); 48 | should.equal(book.isHoliday('2018-12-30'), true); 49 | }); 50 | 51 | it('isWeekend', () => { 52 | should.equal(Book.isWeekend('2018-12-29'), true); 53 | should.equal(Book.isWeekend('2018-12-30'), true); 54 | should.equal(Book.isWeekend('2018-12-31'), false); 55 | }); 56 | }); 57 | -------------------------------------------------------------------------------- /src/book.js: -------------------------------------------------------------------------------- 1 | import moment from 'moment'; 2 | 3 | /** 4 | * @class Book 5 | * @hideconstructor 6 | */ 7 | class Book { 8 | constructor(events) { 9 | this.eventsData = events; 10 | } 11 | 12 | /** 13 | * return all holidays 14 | * @returns {Array} all holidays 15 | */ 16 | all() { 17 | return this.events().filter((event) => event.isHoliday()); 18 | } 19 | 20 | /** 21 | * check date is holiday or not 22 | * @param {Date} date date 23 | * @returns {boolean} 24 | */ 25 | isHoliday(date) { 26 | const event = this.event(date); 27 | 28 | if (!event) { 29 | return Book.isWeekend(date); 30 | } 31 | 32 | return event.isHoliday(); 33 | } 34 | 35 | /** 36 | * check data is workingday or not 37 | * @param {Date} date date 38 | * @returns {boolean} 39 | */ 40 | isWorkingday(date) { 41 | const event = this.event(date); 42 | 43 | if (!event) { 44 | return !Book.isWeekend(date); 45 | } 46 | 47 | return event.isWorkingday(); 48 | } 49 | 50 | /** 51 | * return all events 52 | * @returns {Array} all events 53 | */ 54 | events() { 55 | return this.eventsData; 56 | } 57 | 58 | event(date) { 59 | return this.book()[Book.key(date)]; 60 | } 61 | 62 | book() { 63 | if (!this.bookData) { 64 | this.bookData = {}; 65 | 66 | this.events().forEach((event) => { 67 | event.days().forEach((date) => { 68 | this.bookData[Book.key(date)] = event; 69 | }); 70 | }); 71 | } 72 | 73 | return this.bookData; 74 | } 75 | 76 | static isWeekend(date) { 77 | const day = moment(date).day(); 78 | return day === 6 || day === 0; 79 | } 80 | 81 | static key(date) { 82 | return moment(date).format('YYYY-MM-DD'); 83 | } 84 | } 85 | 86 | 87 | module.exports = Book; 88 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import _isFunction from 'lodash/isFunction'; 2 | import util from 'util'; 3 | 4 | import Book from './book'; 5 | import Bundled from './bundled'; 6 | import Cache from './cache'; 7 | 8 | /* 9 | ChineseHolidays.ready().then(function(book){ 10 | book.isHoliday(date) 11 | }) 12 | 13 | async function example() { 14 | var book = await ChineseHolidays.ready() 15 | book.isHoliday(date) 16 | } 17 | 18 | ChineseHolidays.ready(function(book){ 19 | book.isHoliday(date) 20 | }) 21 | */ 22 | 23 | 24 | function invokeCallback(cb, book) { 25 | if (_isFunction(cb)) { 26 | const callbackFunc = util.deprecate(cb, 'ChineseHolidays.ready(callback) is deprecated, use ChineseHolidays.ready().then(callback) instead.', 'Deprecation API'); 27 | callbackFunc(book, null); 28 | } 29 | } 30 | 31 | 32 | /** 33 | * @class ChineseHolidays 34 | * @hideconstructor 35 | */ 36 | class ChineseHolidays { 37 | /** 38 | * @typedef {Object} options 39 | * @property {boolean} [offline=false] whether to update data from remote 40 | */ 41 | 42 | /** 43 | * @callback bookCallback 44 | * @param {Book} book 45 | */ 46 | 47 | /** 48 | * load events from cache or bundled data 49 | * @param {(options | bookCallback)} options options or callback 50 | * @returns {Promise} 51 | */ 52 | static ready(optionsOrCallback) { 53 | // priority: online data => offline data => bundled data 54 | return new Promise((resolve) => { 55 | const options = optionsOrCallback; 56 | if (options && options.offline) { 57 | const book = new Book(Bundled.events()); 58 | resolve(book); 59 | return; 60 | } 61 | 62 | Cache.events().then((events) => { 63 | const book = new Book(events); 64 | resolve(book); 65 | invokeCallback(optionsOrCallback, book); 66 | }).catch(() => { 67 | const book = new Book(Bundled.events()); 68 | resolve(book); 69 | invokeCallback(optionsOrCallback, book); 70 | }); 71 | }); 72 | } 73 | } 74 | 75 | module.exports = ChineseHolidays; 76 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # chinese-holidays 2 | 3 | 提供具有中国特色的休假安排或者工作日查询。 4 | 5 | ### Install 6 | 7 | npm install chinese-holidays 8 | 9 | ### Usage 10 | 11 | 支持在线更新数据和本地离线数据两种方式。 12 | 13 | ```javascript 14 | var ChineseHolidays = require('chinese-holidays'); 15 | 16 | ChineseHolidays.ready().then(function(book, err){ 17 | if err != null { 18 | return 19 | } 20 | 21 | 元旦 = new Date(2016, 0, 1) 22 | // 是否休假(含正常的周六、周日) 23 | book.isHoliday(元旦) 24 | // true 25 | 26 | // 是否是工作日(含节假日的调休) 27 | book.isWorkingday(元旦) 28 | // fase 29 | 30 | 31 | // 列出已知的节假日 32 | book.all().forEach(function(holiday){ 33 | console.log(holiday.name) 34 | console.log(holiday.days().map(function(date) { return moment(date).format('YYYY-MM-DD') })) 35 | }) 36 | // 元旦 37 | // ["2016-01-01", "2016-01-02", "2016-01-03"] 38 | // ... 39 | 40 | // 列出所有的特殊日子(节假日和调休) 41 | book.events().forEach(function(event){ 42 | console.log(event.name, event.days(), event.isHoliday(), event.isWorkingday()) 43 | }) 44 | }) 45 | 46 | 47 | // disable update from remote, default is false. 48 | const options = { 49 | offline: true 50 | }; 51 | ChineseHolidays.ready(options) 52 | ``` 53 | 54 | ### Documentation 55 | 56 | [API documentation](https://bastengao.com/chinese-holidays-node/) 57 | 58 | ### Support 59 | 60 | 支持在线更新[节假日数据](https://github.com/bastengao/chinese-holidays-data),如果无法联网则使用本地打包的数据。 61 | 62 | * [支持 2026 年](https://www.gov.cn/zhengce/zhengceku/202511/content_7047091.htm) 63 | * [支持 2025 年](https://www.gov.cn/zhengce/content/202411/content_6986382.htm) 64 | * [支持 2024 年](https://www.gov.cn/zhengce/content/202310/content_6911527.htm) 65 | * [支持 2023 年](http://www.gov.cn/zhengce/content/2022-12/08/content_5730844.htm) 66 | * [支持 2022 年](http://www.gov.cn/zhengce/content/2021-10/25/content_5644835.htm) 67 | * [支持 2021 年](http://www.gov.cn/zhengce/content/2020-11/25/content_5564127.htm) 68 | * [支持 2020 年](http://www.gov.cn/zhengce/content/2019-11/21/content_5454164.htm) 69 | * [支持 2019 年](http://www.gov.cn/zhengce/content/2018-12/06/content_5346276.htm) [五一假期调整](http://www.gov.cn/zhengce/content/2019-03/22/content_5375877.htm) 70 | * [支持 2018 年](http://www.gov.cn/zhengce/content/2017-11/30/content_5243579.htm) 71 | * [支持 2017 年](http://www.gov.cn/zhengce/content/2016-12/01/content_5141603.htm) 72 | * 支持 2016 年 73 | 74 | ### References 75 | 76 | * http://www.gov.cn/zhengce/content/2015-12/10/content_10394.htm 77 | 78 | ### License 79 | 80 | The package is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT). 81 | -------------------------------------------------------------------------------- /docs/scripts/search.js: -------------------------------------------------------------------------------- 1 | 2 | var searchAttr = 'data-search-mode'; 3 | function contains(a,m){ 4 | return (a.textContent || a.innerText || "").toUpperCase().indexOf(m) !== -1; 5 | }; 6 | 7 | //on search 8 | document.getElementById("nav-search").addEventListener("keyup", function(event) { 9 | var search = this.value.toUpperCase(); 10 | 11 | if (!search) { 12 | //no search, show all results 13 | document.documentElement.removeAttribute(searchAttr); 14 | 15 | document.querySelectorAll("nav > ul > li:not(.level-hide)").forEach(function(elem) { 16 | elem.style.display = "block"; 17 | }); 18 | 19 | if (typeof hideAllButCurrent === "function"){ 20 | //let's do what ever collapse wants to do 21 | hideAllButCurrent(); 22 | } else { 23 | //menu by default should be opened 24 | document.querySelectorAll("nav > ul > li > ul li").forEach(function(elem) { 25 | elem.style.display = "block"; 26 | }); 27 | } 28 | } else { 29 | //we are searching 30 | document.documentElement.setAttribute(searchAttr, ''); 31 | 32 | //show all parents 33 | document.querySelectorAll("nav > ul > li").forEach(function(elem) { 34 | elem.style.display = "block"; 35 | }); 36 | document.querySelectorAll("nav > ul").forEach(function(elem) { 37 | elem.style.display = "block"; 38 | }); 39 | //hide all results 40 | document.querySelectorAll("nav > ul > li > ul li").forEach(function(elem) { 41 | elem.style.display = "none"; 42 | }); 43 | //show results matching filter 44 | document.querySelectorAll("nav > ul > li > ul a").forEach(function(elem) { 45 | if (!contains(elem.parentNode, search)) { 46 | return; 47 | } 48 | elem.parentNode.style.display = "block"; 49 | }); 50 | //hide parents without children 51 | document.querySelectorAll("nav > ul > li").forEach(function(parent) { 52 | var countSearchA = 0; 53 | parent.querySelectorAll("a").forEach(function(elem) { 54 | if (contains(elem, search)) { 55 | countSearchA++; 56 | } 57 | }); 58 | 59 | var countUl = 0; 60 | var countUlVisible = 0; 61 | parent.querySelectorAll("ul").forEach(function(ulP) { 62 | // count all elements that match the search 63 | if (contains(ulP, search)) { 64 | countUl++; 65 | } 66 | 67 | // count all visible elements 68 | var children = ulP.children 69 | for (i=0; i ul.collapse_top").forEach(function(parent) { 86 | var countVisible = 0; 87 | parent.querySelectorAll("li").forEach(function(elem) { 88 | if (elem.style.display !== "none") { 89 | countVisible++; 90 | } 91 | }); 92 | 93 | if (countVisible == 0) { 94 | //has no child at all and does not contain text 95 | parent.style.display = "none"; 96 | } 97 | }); 98 | } 99 | }); -------------------------------------------------------------------------------- /src/cache.js: -------------------------------------------------------------------------------- 1 | import fs from 'fs'; 2 | import path from 'path'; 3 | import request from 'request'; 4 | import rq from 'request-promise-native'; 5 | import crypto from 'crypto'; 6 | import Bundled from './bundled'; 7 | import Days from './days'; 8 | 9 | const DataEndpoint = 'http://chinese-holidays-data.basten.me/data'; 10 | const IndexUrl = `${DataEndpoint}/index.json`; 11 | const CacheDir = path.resolve(__dirname, '../cache'); 12 | const NewCacheDir = path.resolve(__dirname, '../cache_temp'); 13 | const version = '1.8.0'; 14 | const userAgent = `chinese-holidays-node/${version}`; 15 | 16 | // TODO: checkUpdateInterval 检查更新周期 17 | 18 | // 1. check index file changed 19 | // 2. down load index and data file to new cache dir 20 | // 3. check file syntax 21 | // 4. swithc to new cache dir 22 | const Cache = { 23 | verbose: false, 24 | events() { 25 | return this.loadEventsFromRemote(); 26 | }, 27 | 28 | loadEventsFromRemote() { 29 | const self = this; 30 | if (!fs.existsSync(CacheDir)) { 31 | fs.mkdirSync(CacheDir); 32 | } 33 | 34 | if (!fs.existsSync(NewCacheDir)) { 35 | fs.mkdirSync(NewCacheDir); 36 | } 37 | 38 | return new Promise((resolve, reject) => { 39 | if (self.verbose) { 40 | console.log(`loading data from ${IndexUrl}`); 41 | } 42 | 43 | const options = { 44 | url: IndexUrl, 45 | headers: { 46 | 'User-Agent': userAgent, 47 | }, 48 | }; 49 | request(options, (error, response, body) => { 50 | if (error) { 51 | if (self.verbose) { 52 | console.log(`load failed: ${error}`); 53 | } 54 | reject(error); 55 | return; 56 | } 57 | const indexFile = `${CacheDir}/index.json`; 58 | if (fs.existsSync(indexFile)) { 59 | if (self.checksumFromFile(indexFile) === self.checksumFromContent(body)) { 60 | console.log('same hash skip update'); 61 | resolve(Bundled.loadEventsFromDir(CacheDir)); 62 | return; 63 | } 64 | } 65 | fs.writeFileSync(`${NewCacheDir}/index.json`, body); 66 | 67 | const entries = JSON.parse(body); 68 | entries.sort((a, b) => a.year - b.year); 69 | 70 | const promises = self.downloadEntries(entries); 71 | Promise.all(promises).then((bodys) => { 72 | let events = []; 73 | bodys.forEach((bodyOfYear) => { 74 | try { 75 | const valuesOfYear = JSON.parse(bodyOfYear); 76 | const eventsOfYear = valuesOfYear.map((ele) => new Days(ele.name, ele.range, ele.type)); 77 | events = events.concat(eventsOfYear); 78 | } catch (err) { 79 | reject(err); 80 | } 81 | }); 82 | self.moveToCurrentCacheDir(entries); 83 | resolve(events); 84 | }).catch((err) => { 85 | reject(err); 86 | }); 87 | }); 88 | }); 89 | }, 90 | downloadEntries(entries) { 91 | const self = this; 92 | return entries.map((entry) => { 93 | const url = `${DataEndpoint}/${entry.year}.json`; 94 | if (self.verbose) { 95 | console.log(`loading data from ${url}`); 96 | } 97 | const p = rq({ 98 | uri: url, 99 | headers: { 100 | 'User-Agent': userAgent, 101 | }, 102 | }); 103 | 104 | p.then((body) => { 105 | const filename = `${NewCacheDir}/${entry.year}.json`; 106 | fs.writeFileSync(filename, body); 107 | }); 108 | 109 | return p; 110 | }); 111 | }, 112 | moveToCurrentCacheDir(entries) { 113 | let files = ['index.json']; 114 | files = files.concat(entries.map((e) => `${e.year}.json`)); 115 | files.forEach((file) => { 116 | fs.copyFileSync(`${NewCacheDir}/${file}`, `${CacheDir}/${file}`); 117 | fs.unlinkSync(`${NewCacheDir}/${file}`); 118 | }); 119 | }, 120 | checksumFromFile(file) { 121 | return this.checksumFromContent(fs.readFileSync(file, 'utf8')); 122 | }, 123 | checksumFromContent(buff) { 124 | return crypto.createHash('sha256').update(buff).digest('hex'); 125 | }, 126 | }; 127 | 128 | module.exports = Cache; 129 | -------------------------------------------------------------------------------- /docs/days.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | days.js - Documentation 7 | 8 | 9 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 26 | 27 | 28 | 29 | 35 | 36 |
37 | 38 |

days.js

39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 |
47 |
48 |
import moment from 'moment';
 49 | 
 50 | const rangeToDates = function rangeToDates(startDate, endDate) {
 51 |   const dates = [startDate.toDate()];
 52 |   const start = startDate.toDate();
 53 |   for (let i = 1; i < 100; i += 1) {
 54 |     const date = moment(start).add(i, 'days');
 55 |     if (date.isSame(endDate, 'day')) {
 56 |       dates.push(date.toDate());
 57 |       break;
 58 |     } else {
 59 |       dates.push(date.toDate());
 60 |     }
 61 |   }
 62 | 
 63 |   return dates;
 64 | };
 65 | 
 66 | 
 67 | /**
 68 |  * @class Days
 69 |  * @hideconstructor
 70 |  */
 71 | class Days {
 72 |   constructor(name, range, type) {
 73 |     this.name = name;
 74 |     this.range = range;
 75 |     this.type = type;
 76 |   }
 77 | 
 78 |   /**
 79 |    * return if is holiday
 80 |    * @returns {boolean}
 81 |    */
 82 |   isHoliday() {
 83 |     return this.type === 'holiday';
 84 |   }
 85 | 
 86 |   /**
 87 |    * return if is workingday
 88 |    * @returns {boolean}
 89 |    */
 90 |   isWorkingday() {
 91 |     return this.type === 'workingday';
 92 |   }
 93 | 
 94 |   /**
 95 |    * return days
 96 |    * @returns {Array<Date>} days
 97 |    */
 98 |   days() {
 99 |     let startDate = null;
100 |     startDate = moment(this.range[0]);
101 |     if (this.range.length === 1) {
102 |       return [startDate.toDate()];
103 |     }
104 |     if (this.range.length === 2) {
105 |       const endDate = moment(this.range[1]);
106 |       return rangeToDates(startDate, endDate);
107 |     }
108 | 
109 |     // TODO: handel exception
110 |     return [];
111 |   }
112 | }
113 | 
114 | module.exports = Days;
115 | 
116 |
117 |
118 | 119 | 120 | 121 | 122 | 123 | 124 |
125 | 126 |
127 | 128 |
129 | Documentation generated by JSDoc 4.0.0 on Sat Dec 10 2022 18:48:36 GMT+0800 (中国标准时间) using the docdash theme. 130 |
131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | -------------------------------------------------------------------------------- /docs/book.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | book.js - Documentation 7 | 8 | 9 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 26 | 27 | 28 | 29 | 35 | 36 |
37 | 38 |

book.js

39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 |
47 |
48 |
import moment from 'moment';
 49 | 
 50 | /**
 51 |  * @class Book
 52 |  * @hideconstructor
 53 |  */
 54 | class Book {
 55 |   constructor(events) {
 56 |     this.eventsData = events;
 57 |   }
 58 | 
 59 |   /**
 60 |    * return all holidays
 61 |    * @returns {Array<Days>} all holidays
 62 |    */
 63 |   all() {
 64 |     return this.events().filter((event) => event.isHoliday());
 65 |   }
 66 | 
 67 |   /**
 68 |    * check date is holiday or not
 69 |    * @param {Date} date date
 70 |    * @returns {boolean}
 71 |    */
 72 |   isHoliday(date) {
 73 |     const event = this.event(date);
 74 | 
 75 |     if (!event) {
 76 |       return Book.isWeekend(date);
 77 |     }
 78 | 
 79 |     return event.isHoliday();
 80 |   }
 81 | 
 82 |   /**
 83 |    * check data is workingday or not
 84 |    * @param {Date} date date
 85 |    * @returns {boolean}
 86 |    */
 87 |   isWorkingday(date) {
 88 |     const event = this.event(date);
 89 | 
 90 |     if (!event) {
 91 |       return !Book.isWeekend(date);
 92 |     }
 93 | 
 94 |     return event.isWorkingday();
 95 |   }
 96 | 
 97 |   /**
 98 |    * return all events
 99 |    * @returns {Array<Days>} all events
100 |    */
101 |   events() {
102 |     return this.eventsData;
103 |   }
104 | 
105 |   event(date) {
106 |     return this.book()[Book.key(date)];
107 |   }
108 | 
109 |   book() {
110 |     if (!this.bookData) {
111 |       this.bookData = {};
112 | 
113 |       this.events().forEach((event) => {
114 |         event.days().forEach((date) => {
115 |           this.bookData[Book.key(date)] = event;
116 |         });
117 |       });
118 |     }
119 | 
120 |     return this.bookData;
121 |   }
122 | 
123 |   static isWeekend(date) {
124 |     const day = moment(date).day();
125 |     return day === 6 || day === 0;
126 |   }
127 | 
128 |   static key(date) {
129 |     return moment(date).format('YYYY-MM-DD');
130 |   }
131 | }
132 | 
133 | 
134 | module.exports = Book;
135 | 
136 |
137 |
138 | 139 | 140 | 141 | 142 | 143 | 144 |
145 | 146 |
147 | 148 |
149 | Documentation generated by JSDoc 4.0.0 on Sat Dec 10 2022 18:48:36 GMT+0800 (中国标准时间) using the docdash theme. 150 |
151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | -------------------------------------------------------------------------------- /docs/index.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | index.js - Documentation 7 | 8 | 9 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 26 | 27 | 28 | 29 | 35 | 36 |
37 | 38 |

index.js

39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 |
47 |
48 |
import _isFunction from 'lodash/isFunction';
 49 | import util from 'util';
 50 | 
 51 | import Book from './book';
 52 | import Bundled from './bundled';
 53 | import Cache from './cache';
 54 | 
 55 | /*
 56 | ChineseHolidays.ready().then(function(book){
 57 |   book.isHoliday(date)
 58 | })
 59 | 
 60 | async function example() {
 61 |   var book = await ChineseHolidays.ready()
 62 |   book.isHoliday(date)
 63 | }
 64 | 
 65 | ChineseHolidays.ready(function(book){
 66 |   book.isHoliday(date)
 67 | })
 68 | */
 69 | 
 70 | 
 71 | function invokeCallback(cb, book) {
 72 |   if (_isFunction(cb)) {
 73 |     const callbackFunc = util.deprecate(cb, 'ChineseHolidays.ready(callback) is deprecated, use ChineseHolidays.ready().then(callback) instead.', 'Deprecation API');
 74 |     callbackFunc(book, null);
 75 |   }
 76 | }
 77 | 
 78 | 
 79 | /**
 80 |  * @class ChineseHolidays
 81 |  * @hideconstructor
 82 |  */
 83 | class ChineseHolidays {
 84 |   /**
 85 |    * @typedef {Object} options
 86 |    * @property {boolean} [offline=false] whether to update data from remote
 87 |    */
 88 | 
 89 |   /**
 90 |    * @callback bookCallback
 91 |    * @param {Book} book
 92 |    */
 93 | 
 94 |   /**
 95 |    * load events from cache or bundled data
 96 |    * @param {(options | bookCallback)} options options or callback
 97 |    * @returns {Promise<Book>}
 98 |    */
 99 |   static ready(optionsOrCallback) {
100 |     // priority: online data => offline data => bundled data
101 |     return new Promise((resolve) => {
102 |       const options = optionsOrCallback;
103 |       if (options && options.offline) {
104 |         const book = new Book(Bundled.events());
105 |         resolve(book);
106 |         return;
107 |       }
108 | 
109 |       Cache.events().then((events) => {
110 |         const book = new Book(events);
111 |         resolve(book);
112 |         invokeCallback(optionsOrCallback, book);
113 |       }).catch(() => {
114 |         const book = new Book(Bundled.events());
115 |         resolve(book);
116 |         invokeCallback(optionsOrCallback, book);
117 |       });
118 |     });
119 |   }
120 | }
121 | 
122 | module.exports = ChineseHolidays;
123 | 
124 |
125 |
126 | 127 | 128 | 129 | 130 | 131 | 132 |
133 | 134 |
135 | 136 |
137 | Documentation generated by JSDoc 4.0.0 on Sat Dec 10 2022 18:48:36 GMT+0800 (中国标准时间) using the docdash theme. 138 |
139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Home - Documentation 7 | 8 | 9 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 26 | 27 | 28 | 29 | 35 | 36 |
37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 |
47 |

48 |
49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 |
63 |

chinese-holidays

64 |

提供具有中国特色的休假安排或者工作日查询。

65 |

Install

66 |
npm install chinese-holidays
 67 | 
68 |

Usage

69 |

v1.1.0+ 支持在线更新数据和本地离线数据两种方式。

70 |

v0.4.1 支持最新的 2019 年离线数据,请看 v0.4.1 使用教程

71 |
var ChineseHolidays = require('chinese-holidays');
 72 | 
 73 | ChineseHolidays.ready().then(function(book, err){
 74 |   if err != null {
 75 |     return
 76 |   }
 77 | 
 78 |   元旦 = new Date(2016, 0, 1)
 79 |   // 是否休假(含正常的周六、周日)
 80 |   book.isHoliday(元旦)
 81 |   // true
 82 | 
 83 |   // 是否是工作日(含节假日的调休)
 84 |   book.isWorkingday(元旦)
 85 |   // fase
 86 | 
 87 | 
 88 |   // 列出已知的节假日
 89 |   book.all().forEach(function(holiday){
 90 |     console.log(holiday.name)
 91 |     console.log(holiday.days().map(function(date) { return moment(date).format('YYYY-MM-DD') }))
 92 |   })
 93 |   // 元旦
 94 |   // ["2016-01-01", "2016-01-02", "2016-01-03"]
 95 |   // ...
 96 | 
 97 |   // 列出所有的特殊日子(节假日和调休)
 98 |   book.events().forEach(function(event){
 99 |     console.log(event.name, event.days(), event.isHoliday(), event.isWorkingday())
100 |   })
101 | })
102 | 
103 | 
104 | // disable update from remote, default is false.
105 | const options = {
106 |   offline: true
107 | };
108 | ChineseHolidays.ready(options)
109 | 
110 |

Support

111 |

支持在线更新节假日数据,如果无法联网则使用本地打包的数据。

112 | 122 |

References

123 |
    124 |
  • http://www.gov.cn/zhengce/content/2015-12/10/content_10394.htm
  • 125 |
126 |

License

127 |

The package is available as open source under the terms of the MIT License.

128 |
129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 |
138 | 139 |
140 | 141 |
142 | Documentation generated by JSDoc 4.0.0 on Sat Dec 10 2022 18:48:36 GMT+0800 (中国标准时间) using the docdash theme. 143 |
144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | -------------------------------------------------------------------------------- /docs/ChineseHolidays.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ChineseHolidays - Documentation 7 | 8 | 9 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 26 | 27 | 28 | 29 | 35 | 36 |
37 | 38 |

ChineseHolidays

39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 |
47 | 48 |
49 | 50 |

51 | 52 | ChineseHolidays 53 | 54 |

55 | 56 | 57 |
58 | 59 |
60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 |

Methods

78 | 79 | 80 | 81 | 82 | 83 | 84 |

(static) ready(options) → {Promise.<Book>}

85 | 86 | 87 | 88 | 89 | 90 | 91 |
92 | 93 |
Description:
94 |
  • load events from cache or bundled data
95 | 96 | 97 | 98 |
Source:
99 |
102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 |
134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 |
Parameters:
148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 |
NameTypeDescription
options 176 | 177 | 178 | options 179 | | 180 | 181 | bookCallback 182 | 183 | 184 | 185 | 186 | options or callback
198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 |
Returns:
215 | 216 | 217 | 218 | 219 |
220 |
221 | Type 222 |
223 |
224 | 225 | Promise.<Book> 226 | 227 | 228 | 229 |
230 |
231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 |
243 | 244 |
245 | 246 | 247 | 248 | 249 | 250 | 251 |
252 | 253 |
254 | 255 |
256 | Documentation generated by JSDoc 4.0.0 on Sat Dec 10 2022 18:48:36 GMT+0800 (中国标准时间) using the docdash theme. 257 |
258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | -------------------------------------------------------------------------------- /docs/Days.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Days - Documentation 7 | 8 | 9 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 26 | 27 | 28 | 29 | 35 | 36 |
37 | 38 |

Days

39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 |
47 | 48 |
49 | 50 |

51 | 52 | Days 53 | 54 |

55 | 56 | 57 |
58 | 59 |
60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 |

Methods

78 | 79 | 80 | 81 | 82 | 83 | 84 |

days() → {Array.<Date>}

85 | 86 | 87 | 88 | 89 | 90 | 91 |
92 | 93 |
Description:
94 |
  • return days
95 | 96 | 97 | 98 |
Source:
99 |
102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 |
134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 |
Returns:
162 | 163 | 164 |
165 | days 166 |
167 | 168 | 169 | 170 |
171 |
172 | Type 173 |
174 |
175 | 176 | Array.<Date> 177 | 178 | 179 | 180 |
181 |
182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 |

isHoliday() → {boolean}

193 | 194 | 195 | 196 | 197 | 198 | 199 |
200 | 201 |
Description:
202 |
  • return if is holiday
203 | 204 | 205 | 206 |
Source:
207 |
210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 |
242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 |
Returns:
270 | 271 | 272 | 273 | 274 |
275 |
276 | Type 277 |
278 |
279 | 280 | boolean 281 | 282 | 283 | 284 |
285 |
286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 |

isWorkingday() → {boolean}

297 | 298 | 299 | 300 | 301 | 302 | 303 |
304 | 305 |
Description:
306 |
  • return if is workingday
307 | 308 | 309 | 310 |
Source:
311 |
314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 |
346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 |
Returns:
374 | 375 | 376 | 377 | 378 |
379 |
380 | Type 381 |
382 |
383 | 384 | boolean 385 | 386 | 387 | 388 |
389 |
390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 |
402 | 403 |
404 | 405 | 406 | 407 | 408 | 409 | 410 |
411 | 412 |
413 | 414 |
415 | Documentation generated by JSDoc 4.0.0 on Sat Dec 10 2022 18:48:36 GMT+0800 (中国标准时间) using the docdash theme. 416 |
417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | -------------------------------------------------------------------------------- /docs/global.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Global - Documentation 7 | 8 | 9 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 26 | 27 | 28 | 29 | 35 | 36 |
37 | 38 |

Global

39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 |
47 | 48 |
49 | 50 |

51 | 52 | 53 | 54 |

55 | 56 | 57 |
58 | 59 |
60 | 61 |
62 | 63 | 64 | 65 |
66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 |
100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 |
109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 |

Type Definitions

129 | 130 | 131 | 132 | 133 | 134 | 135 |

bookCallback(book)

136 | 137 | 138 | 139 | 140 | 141 | 142 |
143 | 144 | 145 | 146 |
Source:
147 |
150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 |
182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 |
Parameters:
196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 |
NameTypeDescription
book 224 | 225 | 226 | Book 227 | 228 | 229 | 230 | 231 |
243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 |

options

265 | 266 | 267 | 268 | 269 | 270 |
271 | 272 | 273 | 274 |
Source:
275 |
278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 |
310 | 311 | 312 | 313 |
Properties:
314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 355 | 356 | 357 | 364 | 365 | 366 | 367 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 |
NameTypeAttributesDefaultDescription
offline 347 | 348 | 349 | boolean 350 | 351 | 352 | 353 | 354 | 358 | 359 | <optional>
360 | 361 | 362 | 363 |
368 | 369 | false 370 | 371 | whether to update data from remote
380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 |
Type:
389 |
    390 |
  • 391 | 392 | Object 393 | 394 | 395 | 396 |
  • 397 |
398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 |
409 | 410 |
411 | 412 | 413 | 414 | 415 | 416 | 417 |
418 | 419 |
420 | 421 |
422 | Documentation generated by JSDoc 4.0.0 on Sat Dec 10 2022 18:48:36 GMT+0800 (中国标准时间) using the docdash theme. 423 |
424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | -------------------------------------------------------------------------------- /docs/Book.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Book - Documentation 7 | 8 | 9 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 26 | 27 | 28 | 29 | 35 | 36 |
37 | 38 |

Book

39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 |
47 | 48 |
49 | 50 |

51 | 52 | Book 53 | 54 |

55 | 56 | 57 |
58 | 59 |
60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 |

Methods

78 | 79 | 80 | 81 | 82 | 83 | 84 |

all() → {Array.<Days>}

85 | 86 | 87 | 88 | 89 | 90 | 91 |
92 | 93 |
Description:
94 |
  • return all holidays
95 | 96 | 97 | 98 |
Source:
99 |
102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 |
134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 |
Returns:
162 | 163 | 164 |
165 | all holidays 166 |
167 | 168 | 169 | 170 |
171 |
172 | Type 173 |
174 |
175 | 176 | Array.<Days> 177 | 178 | 179 | 180 |
181 |
182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 |

events() → {Array.<Days>}

193 | 194 | 195 | 196 | 197 | 198 | 199 |
200 | 201 |
Description:
202 |
  • return all events
203 | 204 | 205 | 206 |
Source:
207 |
210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 |
242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 |
Returns:
270 | 271 | 272 |
273 | all events 274 |
275 | 276 | 277 | 278 |
279 |
280 | Type 281 |
282 |
283 | 284 | Array.<Days> 285 | 286 | 287 | 288 |
289 |
290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 |

isHoliday(date) → {boolean}

301 | 302 | 303 | 304 | 305 | 306 | 307 |
308 | 309 |
Description:
310 |
  • check date is holiday or not
311 | 312 | 313 | 314 |
Source:
315 |
318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 |
350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 |
Parameters:
364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 |
NameTypeDescription
date 392 | 393 | 394 | Date 395 | 396 | 397 | 398 | 399 | date
411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 |
Returns:
428 | 429 | 430 | 431 | 432 |
433 |
434 | Type 435 |
436 |
437 | 438 | boolean 439 | 440 | 441 | 442 |
443 |
444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 |

isWorkingday(date) → {boolean}

455 | 456 | 457 | 458 | 459 | 460 | 461 |
462 | 463 |
Description:
464 |
  • check data is workingday or not
465 | 466 | 467 | 468 |
Source:
469 |
472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 |
504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 |
Parameters:
518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | 536 | 537 | 538 | 539 | 540 | 541 | 542 | 543 | 544 | 545 | 554 | 555 | 556 | 557 | 558 | 559 | 560 | 561 | 562 | 563 | 564 |
NameTypeDescription
date 546 | 547 | 548 | Date 549 | 550 | 551 | 552 | 553 | date
565 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 |
Returns:
582 | 583 | 584 | 585 | 586 |
587 |
588 | Type 589 |
590 |
591 | 592 | boolean 593 | 594 | 595 | 596 |
597 |
598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | 608 | 609 |
610 | 611 |
612 | 613 | 614 | 615 | 616 | 617 | 618 |
619 | 620 |
621 | 622 |
623 | Documentation generated by JSDoc 4.0.0 on Sat Dec 10 2022 18:48:36 GMT+0800 (中国标准时间) using the docdash theme. 624 |
625 | 626 | 627 | 628 | 629 | 630 | 631 | 632 | 633 | -------------------------------------------------------------------------------- /docs/scripts/prettify/Apache-License-2.0.txt: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /docs/scripts/prettify/prettify.js: -------------------------------------------------------------------------------- 1 | var q=null;window.PR_SHOULD_USE_CONTINUATION=!0; 2 | (function(){function L(a){function m(a){var f=a.charCodeAt(0);if(f!==92)return f;var b=a.charAt(1);return(f=r[b])?f:"0"<=b&&b<="7"?parseInt(a.substring(1),8):b==="u"||b==="x"?parseInt(a.substring(2),16):a.charCodeAt(1)}function e(a){if(a<32)return(a<16?"\\x0":"\\x")+a.toString(16);a=String.fromCharCode(a);if(a==="\\"||a==="-"||a==="["||a==="]")a="\\"+a;return a}function h(a){for(var f=a.substring(1,a.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),a= 3 | [],b=[],o=f[0]==="^",c=o?1:0,i=f.length;c122||(d<65||j>90||b.push([Math.max(65,j)|32,Math.min(d,90)|32]),d<97||j>122||b.push([Math.max(97,j)&-33,Math.min(d,122)&-33]))}}b.sort(function(a,f){return a[0]-f[0]||f[1]-a[1]});f=[];j=[NaN,NaN];for(c=0;ci[0]&&(i[1]+1>i[0]&&b.push("-"),b.push(e(i[1])));b.push("]");return b.join("")}function y(a){for(var f=a.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),b=f.length,d=[],c=0,i=0;c=2&&a==="["?f[c]=h(j):a!=="\\"&&(f[c]=j.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return f.join("")}for(var t=0,s=!1,l=!1,p=0,d=a.length;p=5&&"lang-"===b.substring(0,5))&&!(o&&typeof o[1]==="string"))c=!1,b="src";c||(r[f]=b)}i=d;d+=f.length;if(c){c=o[1];var j=f.indexOf(c),k=j+c.length;o[2]&&(k=f.length-o[2].length,j=k-c.length);b=b.substring(5);B(l+i,f.substring(0,j),e,p);B(l+i+j,c,C(b,c),p);B(l+i+k,f.substring(k),e,p)}else p.push(l+i,b)}a.e=p}var h={},y;(function(){for(var e=a.concat(m), 9 | l=[],p={},d=0,g=e.length;d=0;)h[n.charAt(k)]=r;r=r[1];n=""+r;p.hasOwnProperty(n)||(l.push(r),p[n]=q)}l.push(/[\S\s]/);y=L(l)})();var t=m.length;return e}function u(a){var m=[],e=[];a.tripleQuotedStrings?m.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):a.multiLineStrings?m.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/, 10 | q,"'\"`"]):m.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,q,"\"'"]);a.verbatimStrings&&e.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,q]);var h=a.hashComments;h&&(a.cStyleComments?(h>1?m.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,q,"#"]):m.push(["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\n\r]*)/,q,"#"]),e.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,q])):m.push(["com",/^#[^\n\r]*/, 11 | q,"#"]));a.cStyleComments&&(e.push(["com",/^\/\/[^\n\r]*/,q]),e.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,q]));a.regexLiterals&&e.push(["lang-regex",/^(?:^^\.?|[!+-]|!=|!==|#|%|%=|&|&&|&&=|&=|\(|\*|\*=|\+=|,|-=|->|\/|\/=|:|::|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|[?@[^]|\^=|\^\^|\^\^=|{|\||\|=|\|\||\|\|=|~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\s*(\/(?=[^*/])(?:[^/[\\]|\\[\S\s]|\[(?:[^\\\]]|\\[\S\s])*(?:]|$))+\/)/]);(h=a.types)&&e.push(["typ",h]);a=(""+a.keywords).replace(/^ | $/g, 12 | "");a.length&&e.push(["kwd",RegExp("^(?:"+a.replace(/[\s,]+/g,"|")+")\\b"),q]);m.push(["pln",/^\s+/,q," \r\n\t\xa0"]);e.push(["lit",/^@[$_a-z][\w$@]*/i,q],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,q],["pln",/^[$_a-z][\w$@]*/i,q],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,q,"0123456789"],["pln",/^\\[\S\s]?/,q],["pun",/^.[^\s\w"-$'./@\\`]*/,q]);return x(m,e)}function D(a,m){function e(a){switch(a.nodeType){case 1:if(k.test(a.className))break;if("BR"===a.nodeName)h(a), 13 | a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)e(a);break;case 3:case 4:if(p){var b=a.nodeValue,d=b.match(t);if(d){var c=b.substring(0,d.index);a.nodeValue=c;(b=b.substring(d.index+d[0].length))&&a.parentNode.insertBefore(s.createTextNode(b),a.nextSibling);h(a);c||a.parentNode.removeChild(a)}}}}function h(a){function b(a,d){var e=d?a.cloneNode(!1):a,f=a.parentNode;if(f){var f=b(f,1),g=a.nextSibling;f.appendChild(e);for(var h=g;h;h=g)g=h.nextSibling,f.appendChild(h)}return e} 14 | for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),e;(e=a.parentNode)&&e.nodeType===1;)a=e;d.push(a)}var k=/(?:^|\s)nocode(?:\s|$)/,t=/\r\n?|\n/,s=a.ownerDocument,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=s.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);for(l=s.createElement("LI");a.firstChild;)l.appendChild(a.firstChild);for(var d=[l],g=0;g=0;){var h=m[e];A.hasOwnProperty(h)?window.console&&console.warn("cannot override language handler %s",h):A[h]=a}}function C(a,m){if(!a||!A.hasOwnProperty(a))a=/^\s*=o&&(h+=2);e>=c&&(a+=2)}}catch(w){"console"in window&&console.log(w&&w.stack?w.stack:w)}}var v=["break,continue,do,else,for,if,return,while"],w=[[v,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"], 18 | "catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],F=[w,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],G=[w,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"], 19 | H=[G,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"],w=[w,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],I=[v,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"], 20 | J=[v,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],v=[v,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],K=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/,N=/\S/,O=u({keywords:[F,H,w,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END"+ 21 | I,J,v],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),A={};k(O,["default-code"]);k(x([],[["pln",/^[^]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\S\s]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\S\s]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]), 22 | ["default-markup","htm","html","mxml","xhtml","xml","xsl"]);k(x([["pln",/^\s+/,q," \t\r\n"],["atv",/^(?:"[^"]*"?|'[^']*'?)/,q,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w-.:]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^\s"'>]*(?:[^\s"'/>]|\/(?=\s)))/],["pun",/^[/<->]+/],["lang-js",/^on\w+\s*=\s*"([^"]+)"/i],["lang-js",/^on\w+\s*=\s*'([^']+)'/i],["lang-js",/^on\w+\s*=\s*([^\s"'>]+)/i],["lang-css",/^style\s*=\s*"([^"]+)"/i],["lang-css",/^style\s*=\s*'([^']+)'/i],["lang-css", 23 | /^style\s*=\s*([^\s"'>]+)/i]]),["in.tag"]);k(x([],[["atv",/^[\S\s]+/]]),["uq.val"]);k(u({keywords:F,hashComments:!0,cStyleComments:!0,types:K}),["c","cc","cpp","cxx","cyc","m"]);k(u({keywords:"null,true,false"}),["json"]);k(u({keywords:H,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:K}),["cs"]);k(u({keywords:G,cStyleComments:!0}),["java"]);k(u({keywords:v,hashComments:!0,multiLineStrings:!0}),["bsh","csh","sh"]);k(u({keywords:I,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}), 24 | ["cv","py"]);k(u({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["perl","pl","pm"]);k(u({keywords:J,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb"]);k(u({keywords:w,cStyleComments:!0,regexLiterals:!0}),["js"]);k(u({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes", 25 | hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]);k(x([],[["str",/^[\S\s]+/]]),["regex"]);window.prettyPrintOne=function(a,m,e){var h=document.createElement("PRE");h.innerHTML=a;e&&D(h,e);E({g:m,i:e,h:h});return h.innerHTML};window.prettyPrint=function(a){function m(){for(var e=window.PR_SHOULD_USE_CONTINUATION?l.now()+250:Infinity;p=0){var k=k.match(g),f,b;if(b= 26 | !k){b=n;for(var o=void 0,c=b.firstChild;c;c=c.nextSibling)var i=c.nodeType,o=i===1?o?b:c:i===3?N.test(c.nodeValue)?b:o:o;b=(f=o===b?void 0:o)&&"CODE"===f.tagName}b&&(k=f.className.match(g));k&&(k=k[1]);b=!1;for(o=n.parentNode;o;o=o.parentNode)if((o.tagName==="pre"||o.tagName==="code"||o.tagName==="xmp")&&o.className&&o.className.indexOf("prettyprint")>=0){b=!0;break}b||((b=(b=n.className.match(/\blinenums\b(?::(\d+))?/))?b[1]&&b[1].length?+b[1]:!0:!1)&&D(n,b),d={g:k,h:n,i:b},E(d))}}p ul { 280 | padding: 0 10px; 281 | } 282 | 283 | nav > ul > li > a { 284 | color: #606; 285 | margin-top: 10px; 286 | } 287 | 288 | nav ul ul a { 289 | color: hsl(207, 1%, 60%); 290 | border-left: 1px solid hsl(207, 10%, 86%); 291 | } 292 | 293 | nav ul ul a, 294 | nav ul ul a:active { 295 | padding-left: 20px 296 | } 297 | 298 | nav h2 { 299 | font-size: 13px; 300 | margin: 10px 0 0 0; 301 | padding: 0; 302 | } 303 | 304 | nav > h2 > a { 305 | margin: 10px 0 -10px; 306 | color: #606 !important; 307 | } 308 | 309 | footer { 310 | color: hsl(0, 0%, 28%); 311 | margin-left: 250px; 312 | display: block; 313 | padding: 15px; 314 | font-style: italic; 315 | font-size: 90%; 316 | } 317 | 318 | .ancestors { 319 | color: #999 320 | } 321 | 322 | .ancestors a { 323 | color: #999 !important; 324 | } 325 | 326 | .clear { 327 | clear: both 328 | } 329 | 330 | .important { 331 | font-weight: bold; 332 | color: #950B02; 333 | } 334 | 335 | .yes-def { 336 | text-indent: -1000px 337 | } 338 | 339 | .type-signature { 340 | color: #CA79CA 341 | } 342 | 343 | .type-signature:last-child { 344 | color: #eee; 345 | } 346 | 347 | .name, .signature { 348 | font-family: Consolas, Monaco, 'Andale Mono', monospace 349 | } 350 | 351 | .signature { 352 | color: #fc83ff; 353 | } 354 | 355 | .details { 356 | margin-top: 6px; 357 | border-left: 2px solid #DDD; 358 | line-height: 20px; 359 | font-size: 14px; 360 | } 361 | 362 | .details dt { 363 | width: auto; 364 | float: left; 365 | padding-left: 10px; 366 | } 367 | 368 | .details dd { 369 | margin-left: 70px; 370 | margin-top: 6px; 371 | margin-bottom: 6px; 372 | } 373 | 374 | .details ul { 375 | margin: 0 376 | } 377 | 378 | .details ul { 379 | list-style-type: none 380 | } 381 | 382 | .details pre.prettyprint { 383 | margin: 0 384 | } 385 | 386 | .details .object-value { 387 | padding-top: 0 388 | } 389 | 390 | .description { 391 | margin-bottom: 1em; 392 | margin-top: 1em; 393 | } 394 | 395 | .code-caption { 396 | font-style: italic; 397 | font-size: 107%; 398 | margin: 0; 399 | } 400 | 401 | .prettyprint { 402 | font-size: 14px; 403 | overflow: auto; 404 | } 405 | 406 | .prettyprint.source { 407 | width: inherit; 408 | line-height: 18px; 409 | display: block; 410 | background-color: #0d152a; 411 | color: #aeaeae; 412 | } 413 | 414 | .prettyprint code { 415 | line-height: 18px; 416 | display: block; 417 | background-color: #0d152a; 418 | color: #4D4E53; 419 | } 420 | 421 | .prettyprint > code { 422 | padding: 15px; 423 | } 424 | 425 | .prettyprint .linenums code { 426 | padding: 0 15px 427 | } 428 | 429 | .prettyprint .linenums li:first-of-type code { 430 | padding-top: 15px 431 | } 432 | 433 | .prettyprint code span.line { 434 | display: inline-block 435 | } 436 | 437 | .prettyprint.linenums { 438 | padding-left: 70px; 439 | -webkit-user-select: none; 440 | -moz-user-select: none; 441 | -ms-user-select: none; 442 | user-select: none; 443 | } 444 | 445 | .prettyprint.linenums ol { 446 | padding-left: 0 447 | } 448 | 449 | .prettyprint.linenums li { 450 | border-left: 3px #34446B solid; 451 | } 452 | 453 | .prettyprint.linenums li.selected, .prettyprint.linenums li.selected * { 454 | background-color: #34446B; 455 | } 456 | 457 | .prettyprint.linenums li * { 458 | -webkit-user-select: text; 459 | -moz-user-select: text; 460 | -ms-user-select: text; 461 | user-select: text; 462 | } 463 | 464 | .prettyprint.linenums li code:empty:after { 465 | content:""; 466 | display:inline-block; 467 | width:0px; 468 | } 469 | 470 | table { 471 | border-spacing: 0; 472 | border: 1px solid #ddd; 473 | border-collapse: collapse; 474 | border-radius: 3px; 475 | box-shadow: 0 1px 3px rgba(0,0,0,0.1); 476 | width: 100%; 477 | font-size: 14px; 478 | margin: 1em 0; 479 | } 480 | 481 | td, th { 482 | margin: 0px; 483 | text-align: left; 484 | vertical-align: top; 485 | padding: 10px; 486 | display: table-cell; 487 | } 488 | 489 | thead tr, thead tr { 490 | background-color: #fff; 491 | font-weight: bold; 492 | border-bottom: 1px solid #ddd; 493 | } 494 | 495 | .params .type { 496 | white-space: nowrap; 497 | } 498 | 499 | .params code { 500 | white-space: pre; 501 | } 502 | 503 | .params td, .params .name, .props .name, .name code { 504 | color: #4D4E53; 505 | font-family: Consolas, Monaco, 'Andale Mono', monospace; 506 | font-size: 100%; 507 | } 508 | 509 | .params td { 510 | border-top: 1px solid #eee 511 | } 512 | 513 | .params td.description > p:first-child, .props td.description > p:first-child { 514 | margin-top: 0; 515 | padding-top: 0; 516 | } 517 | 518 | .params td.description > p:last-child, .props td.description > p:last-child { 519 | margin-bottom: 0; 520 | padding-bottom: 0; 521 | } 522 | 523 | span.param-type, .params td .param-type, .param-type dd { 524 | color: #606; 525 | font-family: Consolas, Monaco, 'Andale Mono', monospace 526 | } 527 | 528 | .param-type dt, .param-type dd { 529 | display: inline-block 530 | } 531 | 532 | .param-type { 533 | margin: 14px 0; 534 | } 535 | 536 | .disabled { 537 | color: #454545 538 | } 539 | 540 | /* navicon button */ 541 | .navicon-button { 542 | display: none; 543 | position: relative; 544 | padding: 2.0625rem 1.5rem; 545 | transition: 0.25s; 546 | cursor: pointer; 547 | -webkit-user-select: none; 548 | -moz-user-select: none; 549 | -ms-user-select: none; 550 | user-select: none; 551 | opacity: .8; 552 | } 553 | .navicon-button .navicon:before, .navicon-button .navicon:after { 554 | transition: 0.25s; 555 | } 556 | .navicon-button:hover { 557 | transition: 0.5s; 558 | opacity: 1; 559 | } 560 | .navicon-button:hover .navicon:before, .navicon-button:hover .navicon:after { 561 | transition: 0.25s; 562 | } 563 | .navicon-button:hover .navicon:before { 564 | top: .825rem; 565 | } 566 | .navicon-button:hover .navicon:after { 567 | top: -.825rem; 568 | } 569 | 570 | /* navicon */ 571 | .navicon { 572 | position: relative; 573 | width: 2.5em; 574 | height: .3125rem; 575 | background: #000; 576 | transition: 0.3s; 577 | border-radius: 2.5rem; 578 | } 579 | .navicon:before, .navicon:after { 580 | display: block; 581 | content: ""; 582 | height: .3125rem; 583 | width: 2.5rem; 584 | background: #000; 585 | position: absolute; 586 | z-index: -1; 587 | transition: 0.3s 0.25s; 588 | border-radius: 1rem; 589 | } 590 | .navicon:before { 591 | top: .625rem; 592 | } 593 | .navicon:after { 594 | top: -.625rem; 595 | } 596 | 597 | /* open */ 598 | .nav-trigger:checked + label:not(.steps) .navicon:before, 599 | .nav-trigger:checked + label:not(.steps) .navicon:after { 600 | top: 0 !important; 601 | } 602 | 603 | .nav-trigger:checked + label .navicon:before, 604 | .nav-trigger:checked + label .navicon:after { 605 | transition: 0.5s; 606 | } 607 | 608 | /* Minus */ 609 | .nav-trigger:checked + label { 610 | -webkit-transform: scale(0.75); 611 | transform: scale(0.75); 612 | } 613 | 614 | /* × and + */ 615 | .nav-trigger:checked + label.plus .navicon, 616 | .nav-trigger:checked + label.x .navicon { 617 | background: transparent; 618 | } 619 | 620 | .nav-trigger:checked + label.plus .navicon:before, 621 | .nav-trigger:checked + label.x .navicon:before { 622 | -webkit-transform: rotate(-45deg); 623 | transform: rotate(-45deg); 624 | background: #FFF; 625 | } 626 | 627 | .nav-trigger:checked + label.plus .navicon:after, 628 | .nav-trigger:checked + label.x .navicon:after { 629 | -webkit-transform: rotate(45deg); 630 | transform: rotate(45deg); 631 | background: #FFF; 632 | } 633 | 634 | .nav-trigger:checked + label.plus { 635 | -webkit-transform: scale(0.75) rotate(45deg); 636 | transform: scale(0.75) rotate(45deg); 637 | } 638 | 639 | .nav-trigger:checked ~ nav { 640 | left: 0 !important; 641 | } 642 | 643 | .nav-trigger:checked ~ .overlay { 644 | display: block; 645 | } 646 | 647 | .nav-trigger { 648 | position: fixed; 649 | top: 0; 650 | clip: rect(0, 0, 0, 0); 651 | } 652 | 653 | .overlay { 654 | display: none; 655 | position: fixed; 656 | top: 0; 657 | bottom: 0; 658 | left: 0; 659 | right: 0; 660 | width: 100%; 661 | height: 100%; 662 | background: hsla(0, 0%, 0%, 0.5); 663 | z-index: 1; 664 | } 665 | 666 | /* nav level */ 667 | .level-hide { 668 | display: none; 669 | } 670 | html[data-search-mode] .level-hide { 671 | display: block; 672 | } 673 | 674 | 675 | @media only screen and (max-width: 680px) { 676 | body { 677 | overflow-x: hidden; 678 | } 679 | 680 | nav { 681 | background: #FFF; 682 | width: 250px; 683 | height: 100%; 684 | position: fixed; 685 | top: 0; 686 | right: 0; 687 | bottom: 0; 688 | left: -250px; 689 | z-index: 3; 690 | padding: 0 10px; 691 | transition: left 0.2s; 692 | } 693 | 694 | .navicon-button { 695 | display: inline-block; 696 | position: fixed; 697 | top: 1.5em; 698 | right: 0; 699 | z-index: 2; 700 | } 701 | 702 | #main { 703 | width: 100%; 704 | } 705 | 706 | #main h1.page-title { 707 | margin: 1em 0; 708 | } 709 | 710 | #main section { 711 | padding: 0; 712 | } 713 | 714 | footer { 715 | margin-left: 0; 716 | } 717 | } 718 | 719 | /** Add a '#' to static members */ 720 | [data-type="member"] a::before { 721 | content: '#'; 722 | display: inline-block; 723 | margin-left: -14px; 724 | margin-right: 5px; 725 | } 726 | 727 | #disqus_thread{ 728 | margin-left: 30px; 729 | } 730 | 731 | @font-face { 732 | font-family: 'Montserrat'; 733 | font-style: normal; 734 | font-weight: 400; 735 | src: url('../fonts/Montserrat/Montserrat-Regular.eot'); /* IE9 Compat Modes */ 736 | src: url('../fonts/Montserrat/Montserrat-Regular.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */ 737 | url('../fonts/Montserrat/Montserrat-Regular.woff2') format('woff2'), /* Super Modern Browsers */ 738 | url('../fonts/Montserrat/Montserrat-Regular.woff') format('woff'), /* Pretty Modern Browsers */ 739 | url('../fonts/Montserrat/Montserrat-Regular.ttf') format('truetype'); /* Safari, Android, iOS */ 740 | } 741 | 742 | @font-face { 743 | font-family: 'Montserrat'; 744 | font-style: normal; 745 | font-weight: 700; 746 | src: url('../fonts/Montserrat/Montserrat-Bold.eot'); /* IE9 Compat Modes */ 747 | src: url('../fonts/Montserrat/Montserrat-Bold.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */ 748 | url('../fonts/Montserrat/Montserrat-Bold.woff2') format('woff2'), /* Super Modern Browsers */ 749 | url('../fonts/Montserrat/Montserrat-Bold.woff') format('woff'), /* Pretty Modern Browsers */ 750 | url('../fonts/Montserrat/Montserrat-Bold.ttf') format('truetype'); /* Safari, Android, iOS */ 751 | } 752 | 753 | @font-face { 754 | font-family: 'Source Sans Pro'; 755 | src: url('../fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot'); 756 | src: url('../fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot?#iefix') format('embedded-opentype'), 757 | url('../fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2') format('woff2'), 758 | url('../fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff') format('woff'), 759 | url('../fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf') format('truetype'), 760 | url('../fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg#source_sans_proregular') format('svg'); 761 | font-weight: 400; 762 | font-style: normal; 763 | } 764 | 765 | @font-face { 766 | font-family: 'Source Sans Pro'; 767 | src: url('../fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot'); 768 | src: url('../fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot?#iefix') format('embedded-opentype'), 769 | url('../fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2') format('woff2'), 770 | url('../fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff') format('woff'), 771 | url('../fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf') format('truetype'), 772 | url('../fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg#source_sans_prolight') format('svg'); 773 | font-weight: 300; 774 | font-style: normal; 775 | 776 | } 777 | --------------------------------------------------------------------------------