Socket
Socket
Sign inDemoInstall

cal.js

Package Overview
Dependencies
0
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    cal.js

Generate calendar array.


Version published
Maintainers
1
Install size
40.6 kB
Created

Readme

Source

cal.js

Generate calendar array.

Overview

JavaScriptでカレンダーを作れと言われた経験はありませんか?

  • そして特定月だけじゃなくて、過去にも未来も表示したいと言われたことはありませんか?
  • そのうえ、今月分で余ったマスには前の月と次の月を表示したいとか言われたことはありませんか?
  • あっちでは日曜はじまり、こっちは月曜はじまりって言われてませんか?
  • 今日はそれ用のマークつけたいとか言われますか?

そんな人のためのカレンダー表示用のライブラリです。

Install

npm i cal.js --save

# or
yarn add cal.js

or

<script src="./dist/cal.min.js"></script>

Usage

const Cal = require('cal.js');

// 引数はすべてOptional
const cal = new Cal({
    // 未指定の場合は今日
    year:  2017,
    month: 1,
    date:  13,

    // 週の始まりの曜日 0:日曜 1:月曜 ... 6:土曜
    firstDayOfWeek: 2,

    // [非推奨] 月曜はじまり or NOT(falseは日曜始まり)
    // firstDayOfWeekが指定されている場合は無視され、以下は等価
    // firstDayOfWeek: 0 === fromMonday: false
    // firstDayOfWeek: 1 === fromMonday: true
    fromMonday: true,

    // 未指定の場合は、「月火水木金土日」フォーマット
    // firstDayOfWeekを指定する場合は、並び替えたものを渡す必要がある
    dayStrArr: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
});

cal.getDayArr(); // => 曜日表示用のラベル配列
cal.getCalArr(); // => カレンダー本体の42マスの配列

FAQs

Last updated on 16 Feb 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc