2.0.1 • Published 2 years ago

tw-holiday v2.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

TW Holiday

將 政府行政機關辦公日曆表 提供出 javascript 串接介面

Dataset

政府資料開放平臺 - 政府行政機關辦公日曆表: https://data.gov.tw/dataset/26557

新北市政府資料開放平臺 - 政府行政機關辦公日曆表: https://data.ntpc.gov.tw/datasets/308DCD75-6434-45BC-A95F-584DA4FED251

Installation

GitHub / npm

npm install tw-holiday --save

Example

interface HolidayEvent {
  /** 日期 YYYY-MM-DD */
  date: string;
  /** 節日或紀念日名稱 */
  name: string;
  /** 是否為休假日 */
  isHoliday: boolean;
  /** 放假類別 */
  holidayCategory: string;
  /** 說明 */
  description: string;
  /**
   * - 1: 星期一
   * - 2: 星期二
   * - 3: 星期三
   * - 4: 星期四
   * - 5: 星期五
   * - 6: 星期六
   * - 7: 星期日
   */
  week: number;
}
// javascript
const { Holiday } = require("tw-holiday");
// typescript
import { Holiday } from "tw-holiday";

// 啟用快取, 選用, 預設: false
Holiday.enabledCache = true;

// 設定快取時間, 選用, 預設: 24 * 60 * 60 * 1000, 單位: 毫秒
Holiday.cacheTime = 60 * 1000;

// Holiday.fetchEvents(): Promise<HolidayEvent[]>
Holiday.fetchEvents().then(console.log).catch(console.error);
// Holiday.isHoliday(date: string): Promise<boolean>
Holiday.isHoliday("2021-12-31");
1.1.0

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago