npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

koyomi

v0.5.1

Published

japanese date calculator

Downloads

1,108

Readme

koyomi @ v0.5.1

日本の暦に基づいて日時に計算を行うモジュールです
このモジュールは、サーバサイド、クライアントサイド両対応です

主な機能

  • 日時への変換
  • 日時から文字列へのフォーマット
  • 日にち、時間等の加減算・日数の計算
  • 営業日の加減算・日数の計算
  • 祝日の取得
  • カレンダーデータの取得

利用方法

node

npm経由でインストールしてください

npm install koyomi

var koyomi = require('koyomi');
var wareki = koyomi.format('2015-7-15', 'WAREKI');
var deadline = koyomi.addBiz('2015-5-1', 10);

クライアントサイド

public/koyomi.min.jsを読み込んでください

<script src="koyomi.min.js"></script>
<script>
  var wareki = koyomi.format('2015-7-15', 'WAREKI');
  var deadline = koyomi.addBiz('2015-5-1', 10);
</script>

日本の暦

年度

年度とは、特定の目的のために規定された1年間の区切り方です
日本での会計年度は4月に始まり3月末に終わることが多いため、年度を基準とした計算が必要な場面が多くなります
koyomiでは既定で年の始まりを4月として計算します
(設定で年の始まりを変更できます)

和暦

日本の暦では、年号を使用した日付の表記(和暦)がよく使用されます
koyomiでは和暦でフォーマットすることができます
さらに年区切りと日付区切りの両方をサポートしています

| 年号 | 年区切りの期間 | 日付区切りの期間 | |------|--------------- |-----------------------| | 平成 | 1989年- | 1989/01/08- | | 昭和 | 1926年-1988年 | 1926/12/25-1989/01/07 | | 大正 | 1912年-1925年 | 1912/07/30-1926/12/24 | | 明治 | 1868年-1911年 | 1868/01/25-1912/07/29 |

(注意) 明治は1868年に始まっていますが、グレゴリオ歴の導入が1873年(明治6年)以降のため、それ以前は和暦は旧暦のこよみになります
koyomiでは旧暦のサポートはしていません
そのため、1872年以前での和暦のフォーマットは自動的に西暦表示になります

祝日

koyomiに設定されている祝日は、1948年7月20日に施行された祝日法に基づき計算されています
祝日をフォーマットや営業日の計算に使用できます
祝日データは2015年5月時点で決定されているものが反映されています
(2016年から新しく施行される山の日まで)

営業日

ビジネス上では見積もり時に何営業日で納品など、営業日ベースの計算が必須です
営業日の計算は煩雑になりやすいため、日付を明記することが面倒です
それらを自動計算させることができます

一部機能の紹介

  • フォーマット。koyomi.format('2015-5-5', 'wareki')'平成二十七年五月五日'
  • 加減算。koyomi.add('2015-5-5', '3日')new Date('2015-5-8')
  • 営業日の計算。koyomi.addBiz('2015-5-5', 3)new Date('2015-5-11')
  • 営業日数。koyomi.biz('2015-1-1', '2015-12-31')242

このほかにも多くの機能を利用することができます
詳しくは下記のドキュメントを参照してください

ドキュメント一覧

注意

関数の引数にDATEとある場合は、koyomi.toDateの第一引数に設定できる値です
便宜上DATEとしていますが、Dateインスタンスではないので注意してください
詳しくは補助関数のtoDateの項目で確認してください

使用例などにD2015-11-23とDが先頭に追加された表記があった場合は、new Date(2015, 10, 23)の意味です