New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

diary-header

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

diary-header

A command-line tool that generates a Markdown header for daily diary entries with location, astronomical, and weather information

latest
Source
npmnpm
Version
0.1.11
Version published
Weekly downloads
390
1244.83%
Maintainers
1
Weekly downloads
 
Created
Source

diary-header

A command-line tool written in Rust that interactively generates a Markdown header for your daily diary entries. It automatically retrieves geolocation data, calculates sunrise/sunset times, and determines the sexagenary cycle (干支 - Eto) for any given date.

Features

  • Interactive Prompts: Easily select the date and location using an interactive terminal UI.
  • Location Auto-Detection: Automatically fetches your current location, latitude, longitude, and timezone based on your IP address.
  • Manual Location Selection: Optionally select from a comprehensive list of cities worldwide if you are writing a diary for somewhere else.
  • Astronomical Calculations: Calculates precise sunrise and sunset times based on the selected date and location coordinates.
  • Weather Information: Retrieves daily maximum and minimum temperatures for the selected date and location.
  • Sexagenary Cycle (干支): Automatically computes the traditional continuous calendar cycle (Eto) for the given date.
  • Six-Day Cycle (六曜): Calculates the traditional Japanese six-day cycle (Rokuyo) for fortune-telling and event planning.
  • Language Configuration: Choose between Japanese (ja) and English (en) for the output format.
  • Customizable Display Order: Configure which information to display and in what order via the config file.
  • Persistent Configuration: Prompts for an initial configuration (language) and saves it to a configuration file (~/.config/diary-header/config.toml). You can update this later using the config subcommand.

Installation

The easiest way to install diary-header is via npm:

npm install -g diary-header

This will download a prebuilt binary for your platform and make the diary-header command available globally.

Via Cargo

Alternatively, if you have Rust and Cargo installed, you can install from source:

git clone https://github.com/massn/diary-header.git
cd diary-header
cargo install --path .

Or just run it directly:

cargo run

Usage

When you run diary-header (or cargo run), the tool will interactively prompt you for the necessary information:

  • First-time Setup: If the configuration file does not exist, it will ask for your preferred output language (Japanese or English). This is saved to ~/.config/diary-header/config.toml.
  • Date Selection: Prompts you to select a date for the diary header (defaults to today).
  • Location Selection: Prompts you to choose "Current Location (Auto via IP)" or select a specific city from the list.

Example Output

Once the selections are made, the tool outputs a localized Markdown header depending on your configured language:

Japanese Output (ja):

## 2024-11-20 (水)
- 場所 (Current IP Address): Tokyo (Tokyo)
- 緯度経度: (35.6895, 139.6917)
- タイムゾーン: Asia/Tokyo
- 日の出: 06:21:43 JST+0900
- 日の入り: 16:32:11 JST+0900
- 天気: 晴れ
- 降水確率: 20%
- 気温: 最高 18.5°C / 最低 12.3°C
- 干支: 甲辰
- 六曜: 先勝

English Output (en):

## 2024-11-20 (Wednesday)
- Location (Current IP Address): Tokyo (Tokyo)
- Lat/Lon: (35.6895, 139.6917)
- Timezone: Asia/Tokyo
- Sunrise: 06:21:43 JST+0900
- Sunset: 16:32:11 JST+0900
- Weather: Mainly clear
- Precipitation Probability: 20%
- Temperature: Max 18.5°C / Min 12.3°C
- Sexagenary Cycle: 甲辰
- Rokuyo: 先勝

You can redirect this output directly to your diary file or copy it securely:

diary-header >> my-diary.md

Configuration

The configuration file is stored in ~/.config/diary-header/config.toml (macOS/Linux) or %APPDATA%\diary-header\config.toml (Windows).

Language Setting

You can interactively change the language setting at any time by using the config subcommand:

diary-header config
# Or with cargo:
cargo run -- config

Display Order Customization

You can customize the order of displayed information by manually editing the configuration file. By default, all items are displayed in the following order:

language = "en"
display_order = [
    "location",
    "coordinates",
    "timezone",
    "sunrise",
    "sunset",
    "weather",
    "precipitation",
    "temperature",
    "sexagenary_cycle",
    "rokuyo",
]

Available items:

  • location - Location information (city/region)
  • coordinates - Latitude and longitude
  • timezone - Timezone
  • sunrise - Sunrise time
  • sunset - Sunset time
  • weather - Weather condition
  • precipitation - Precipitation probability
  • temperature - Max/min temperature
  • sexagenary_cycle - Sexagenary cycle (干支)
  • rokuyo - Six-day cycle (六曜)

You can reorder these items or remove items you don't need. For example, to show only weather-related information:

language = "ja"
display_order = [
    "weather",
    "temperature",
    "precipitation",
]

Items not included in display_order will not be displayed in the output.

Dependencies

  • inquire: For interactive terminal prompts (date, select, text).
  • reqwest: For hitting the ip-api.com endpoint to fetch IP-based timezone and geolocation info, and the Open-Meteo API for weather data.
  • sunrise: For calculating the exact sunrise and sunset times.
  • tzf-rs: For fast offline timezone timezone lookups based on longitude and latitude.
  • chrono: For date and time manipulation.
  • cities: For the embedded list of global cities.
  • clap: For CLI argument parsing and subcommands.
  • serde / serde_json / toml: For data serialization and writing/reading the config.

Development

Release Process

The version is managed through package.json, which serves as the single source of truth. The build.rs script automatically reads the version from package.json during compilation.

To create a new release:

  • Update the version in package.json:

    # Edit package.json and update the version field
    # Example: "version": "0.1.9"
    
  • Update Cargo.toml version (optional but recommended):

    # Keep Cargo.toml in sync to avoid confusion
    # Example: version = "0.1.9"
    
  • Update Cargo.lock:

    cargo update -p diary-header
    
  • Build and verify the version:

    cargo build --release
    ./target/release/diary-header --version
    # Should output: diary-header 0.1.9
    
  • Commit the changes:

    git add package.json Cargo.toml Cargo.lock
    git commit -m "chore: bump version to 0.1.9"
    
  • Create a git tag:

    git tag -a v0.1.9 -m "Release v0.1.9"
    
  • Push to remote:

    git push origin main
    git push origin v0.1.9
    
  • Publish to npm:

    npm publish
    

Note: The version displayed by --version comes from package.json, not from git tags. This ensures consistent versioning across npm packages and the binary.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Keywords

diary

FAQs

Package last updated on 02 Apr 2026

Did you know?

Socket

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