Skip to content

taku-o/go-heijitu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

73 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-heijitu

English

go-heijitu は日本の営業日を計算する Go ライブラリです。指定日が営業日か(土日・祝日・除外日付でないか)を判定し、次の営業日・指定年月の最初の営業日・指定年の各月初営業日・期間内の祝日一覧を求めます。祝日データソースは HolidayProvider インターフェースで差し替え可能です。

インストール

go get github.com/taku-o/go-heijitu

クイックスタート

package main

import (
    "context"
    "fmt"
    "time"

    heijitu "github.com/taku-o/go-heijitu"
    "github.com/taku-o/go-heijitu/providers/holidayjp"
)

func main() {
    ctx := context.Background()
    cal := heijitu.New(holidayjp.New())

    // 翌月の最初の営業日を取得する
    next := time.Now().AddDate(0, 1, 0)
    day, _ := cal.FirstBusinessDayOfMonth(ctx, next.Year(), next.Month())

    weekdays := []string{"日", "月", "火", "水", "木", "金", "土"}
    fmt.Printf("翌月の最初の営業日: %s (%s)\n",
        day.Format("2006-01-02"), weekdays[day.Weekday()])
}

プロバイダー

祝日データソースは heijitu.NewHolidayProvider を渡して選択します。

  • holidayjp — 埋め込み祝日データ。ネットワークアクセス不要。
  • caoCsv — 内閣府公式CSV。ローカルファイル/オンライン。
  • googleCalendar — Google Calendar の祝日カレンダー。APIキー/サービスアカウント。

googleCalendar プロバイダーには Google Calendar APIキーが必要です。要点: Google Cloud Console でプロジェクトを作成し、Google Calendar API を有効化、「APIとサービス → 認証情報」でAPIキーを作成し、(推奨)キーを Calendar API のみに制限します。詳細な手順と integration テストの実行方法はプロバイダーガイドを参照してください。

ドキュメント

ライセンス

MIT ライセンス。LICENSE を参照してください。

About

A Go library for getting Japanese business days.

Resources

License

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages