holidays_jp
holidays_jp is a command-line tool for determining Japanese national holidays. It provides a simple and efficient way to check if specific dates are holidays, list holidays within date ranges, and manage holiday data.
Features
- 🗓️ Flexible Date Formats: Supports multiple date formats (YYYYMMDD, YYYY-MM-DD, YYYY/MM/DD, YYYY年MM月DD日, etc.)
- 📊 Multiple Output Formats: Human-readable, JSON, and quiet modes
- 📅 Date Range Support: List all holidays within a specified period
- 🔄 Auto-Update: Automatically updates holiday data from official sources
- 🌐 Offline Support: Works without internet connection after initial setup
- ⚡ Fast & Lightweight: Quick response times and minimal resource usage
Data Source
The holiday data is based on the official CSV file provided by the Cabinet Office of Japan. The data is automatically updated once a week via GitHub Actions, ensuring you always have the latest holiday information.
Note: The data source URL is configurable via
config.toml. See the configuration section for details.
Installation
From Source
Using Cargo
Quick Start
If your PC is connected to the Internet, you can obtain the latest Japanese national holiday data by executing the following command.
# Check today's date (default behavior)
# Check a specific date (with -d option)
)
# Check a specific date (positional argument, no -d required)
)
# Check with different date format
)
# JSON output for scripting
}
# Quiet output (holiday name only)
# Verbose output with additional information
)
List Holidays in a Range
# List holidays in January 2023
)
# JSON output for programmatic use
{
{
}
{
}
{
}
}
# List all holidays in 2023
Update Holiday Data
# Update to the latest holiday data
Get Help
# General help
# Command-specific help
Supported Date Formats
The tool automatically detects and supports various date formats:
YYYYMMDD(e.g.,20230101)YYYY-MM-DD(e.g.,2023-01-01)YYYY/MM/DD(e.g.,2023/01/01)YYYY年MM月DD日(e.g.,2023年1月1日)MM/DD/YYYY(e.g.,01/01/2023)DD/MM/YYYY(e.g.,01/01/2023)YYYY.MM.DD(e.g.,2023.01.01)
Output Formats
- human (default): Human-readable format with clear messages
- json: Structured JSON output for programmatic use
- quiet: Minimal output showing only holiday names
Configuration
The application automatically generates a config.toml file on first run with default settings. You can customize this file to fit your needs.
Configuration File Location
- Auto-generated:
config.toml(created automatically on first run) - Example/Template:
config.toml.example(reference configuration with detailed comments)
Configuration Options
[]
# Data source URL (configurable)
= "https://www8.cao.go.jp/chosei/shukujitsu/syukujitsu.csv"
# Cache file location
= "./data/holidays.json"
[]
# Cache strategy: TimeBased, EtagBased, Hybrid, AlwaysRefresh, NeverRefresh
= "Hybrid"
# Maximum cache age in hours (default: 168 = 7 days)
= 168
# ETag check interval in hours (default: 24 = 1 day)
= 24
# Force refresh on startup
= false
Note: All default configuration values are defined in
src/constants.rs. When you first run the application, it will createconfig.tomlwith these defaults. You can then modifyconfig.tomlto customize the behavior without changing the source code.
Custom Data Sources
You can use custom holiday data sources by modifying the source_url in config.toml. The CSV format should match the official format:
日付,祝日名
2023/1/1,元日
2023/1/2,休日
...