Google Calendarに予定を追加するurlを生成します。
実行例(読み込み方法は下記 Setup を参照)
generateUrl({
start: new Date(2014, 10, 15, 10),
end: new Date(2014, 10, 15, 18),
title: '新しい予定',
location: 'ここではないどこか',
details: 'http://event.description.example.com/11234'
})以下のurlを生成します。
Node.js 26以上が必要です。
インストール
npm install generate-google-calendar-url
実行例(.mjs ファイル、または package.json に "type": "module" を指定したプロジェクトで実行)
import generateUrl from 'generate-google-calendar-url'
generateUrl({
start: new Date(2014, 11, 15, 10),
end: new Date(2014, 11, 15, 18),
title: '新しい予定',
location: 'ここではないどこか',
details: 'http://event.description.example.com/11234'
})Temporal を標準搭載したブラウザが必要です。Safari はサポート対象外です。ポリフィルは同梱しません。
インストール
npm install generate-google-calendar-url
HTML に type="module" の script タグを埋め込みます。以下は node_modules と同じディレクトリに HTML を置く場合の例です。HTTP(S) サーバー経由で開いてください。公開時には JavaScript ファイルを配信先にコピーし、パスを調整してください。
<script type="module">
import generateUrl from './node_modules/generate-google-calendar-url/generate-google-calendar-url.js';
console.log(generateUrl({
start: new Date(2014, 11, 15, 10),
end: new Date(2014, 11, 15, 18),
title: '新しい予定',
location: 'ここではないどこか',
details: 'http://event.description.example.com/11234'
}));
</script>このパッケージは ES モジュールの default export として関数を公開します。従来の require() による関数の取得や window.generateUrl の利用は、上記の import に変更してください。
終日予定は date に YYYY/MM/DD 形式の文字列(月・日は1桁も可)を指定します。不正な日付は無視します。時刻付き予定は start と end に有効な Date オブジェクトを指定します。
- text
- dates
- location
- details
- trp
- sprop
contributeするには
- Fork it.
- Create a branch (git checkout -b my_function)
- Commit your changes (git commit -am "Added My Function")
- Push to the branch (git push origin my_function)
- Open a Pull Request
- Enjoy a refreshing coffe and wait
Node.jsで実行
npm install
npm test