Skip to content

cumulus13/dtime

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dtime

Crates.io Documentation License

A professional, cross-platform datetime display utility with colored output and millisecond precision.

Features

  • 🕒 Display local and UTC time with millisecond precision
  • 📅 Unix timestamps in seconds and milliseconds
  • 🌍 Timezone information with UTC offset
  • 🎨 Beautiful colored output using true color (24-bit)
  • 📊 Multiple output formats: colored, plain text, JSON
  • 🔄 Monitor mode for real-time updates
  • 🖥️ Cross-platform: Windows, Linux, macOS
  • 🚀 Fast and lightweight

Installation

From Crates.io

cargo install dtime

From Source

git clone https://github.com/cumulus13/dtime.git
cd dtime
cargo install --path .

Usage

Basic Usage

# Display current datetime (colored output by default)
dtime

# Plain text output
dtime --format plain

# JSON output
dtime --format json

# Disable colors
dtime --no-color

Advanced Options

# Show ISO 8601 format
dtime --iso

# Monitor mode (updates every 2 seconds)
dtime --monitor 2

# Custom timezone
dtime --timezone "Asia/Jakarta"

# Combine options
dtime --iso --format json

Output Examples

Colored Output (Default)

╔══════════════════════════════════════════════════╗
║         SYSTEM TIME INFORMATION                  ║
╚══════════════════════════════════════════════════╝
┌──────────────────────────────────────────────────┐
│ Local Time:  2024-01-15 14:30:45.123 WIB         │
│ UTC Time:    2024-01-15 07:30:45.123 UTC         │
│ Unix Sec:    1705321845                          │
│ Unix MS:     1705321845123                       │
└──────────────────────────────────────────────────┘

╔══════════════════════════════════════════════════╗
║         TIMEZONE INFORMATION                     ║
╚══════════════════════════════════════════════════╝
┌──────────────────────────────────────────────────┐
│ Timezone:    WIB                                 │
│ Offset:      +07:00                              │
│ Weekday:     Monday                              │
└──────────────────────────────────────────────────┘

JSON Output

{
  "local_time": "2024-01-15 14:30:45.123 WIB",
  "utc_time": "2024-01-15 07:30:45.123 UTC",
  "unix_seconds": 1705321845,
  "unix_milliseconds": 1705321845123,
  "timezone": "WIB",
  "offset": "+07:00",
  "weekday": "Monday",
  "iso_local": "2024-01-15T14:30:45.123+07:00",
  "iso_utc": "2024-01-15T07:30:45.123Z"
}

Using as a Library

Add to your Cargo.toml:

[dependencies]
dtime = "0.1"
use dtime::{DateTimeInfo, Config};

fn main() {
    let config = Config::default();
    let dt_info = DateTimeInfo::new(&config);
    
    // Print colored output
    println!("{}", dt_info.format_colored());
    
    // Get JSON
    let json = dt_info.format_json();
    
    // Access individual fields
    println!("Unix timestamp: {}", dt_info.unix_seconds);
}

License

Licensed under either of:

at your option.

👤 Author

Hadi Cahyadi

Buy Me a Coffee

Donate via Ko-fi

Support me on Patreon

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

About

A professional, cross-platform datetime display utility with colored output and millisecond precision.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages