Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ Cargo.lock

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

# IDE files
.idea/
150 changes: 134 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,153 @@
# week

[![Build & Test](https://github.com/billyto/week/actions/workflows/build.yml/badge.svg)](https://github.com/billyto/week/actions/workflows/build.yml)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

A simple and fast CLI utility to get ISO week numbers (1-53) for any date.

# week
Simple CLI utility to return the ISO week number starting from 1.
## 🚀 Quick Start

```bash
# Get current week number
week

# Get week number for a specific date
week --date 19-02-2023
week -d 15/03/2024
week -d 01.01
```

## 📖 Usage

```
week [OPTIONS]

OPTIONS:
-d, --date <DATE> Date to get week number for (various formats supported)
-h, --help Print help information
-V, --version Print version information
```

### Examples

```bash
# Current week
$ week
Week 24

# Specific date with year
$ week --date 19-02-2023
Week 7

$ week -d 25/12/2023
Week 52

# Date without year (uses current year)
$ week -d 15/03
Week 11

$ week -d 01.01
Week 1
```

## 📅 Supported Date Formats

## Use cases
The tool accepts dates in multiple convenient formats:

| Format | Example | Description |
|--------------|--------------|-------------------------------|
| `DD-MM-YYYY` | `19-02-2023` | Day-Month-Year with dashes |
| `DD/MM/YYYY` | `19/02/2023` | Day-Month-Year with slashes |
| `DD.MM.YYYY` | `19.02.2023` | Day-Month-Year with periods |
| `DD-MM` | `19-02` | Day-Month (uses current year) |
| `DD/MM` | `19/02` | Day-Month (uses current year) |
| `DD.MM` | `19.02` | Day-Month (uses current year) |

> **Note**: All formats use DD-MM ordering (day first, then month)

## 🛠️ Installation

### From Source

```bash
# Clone the repository
git clone https://github.com/billyto/week.git
cd week

# Build and install
cargo install --path week
```
week //The week of the year for today

week [--date date] //Gives the week for 'date'
### From Releases

Download pre-built binaries from the [releases page](https://github.com/billyto/week/releases) for:
- Windows (x86_64)
- Linux (x86_64)
- macOS (x86_64)

## 🧪 Development

### Prerequisites

- Rust 1.70.0 or later
- Cargo

### Building

```bash
cd week
cargo build --release
```

### Running Tests

```bash
# Unit tests
cargo test

# Integration tests
cargo test --test cli
```

### Project Structure

```
week/
├── src/
│ ├── lib.rs # Core date parsing logic
│ └── main.rs # CLI interface
├── tests/
│ └── cli_tests.rs # Integration tests
└── Cargo.toml # Dependencies and metadata
```

## Suported Date formats
* %d-%m-%Y
## 📋 About ISO Week Numbers

* %d/%m/%Y
This tool returns ISO week numbers according to [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601):

* %d/%m
- Week numbers range from 1 to 53
- Week 1 is the first week with at least 4 days in the new year
- Weeks start on Monday
- Some years have 53 weeks

* %d.%m

## 📝 License

---
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

### TODOs:
## 🗺️ Roadmap

[x] fix valid formats, no yeat first and right %xx descriptors
- [x] Support multiple date formats
- [x] CI/CD pipeline for releases
- [x] Comprehensive CLI help
- [x] Integration tests
- [ ] Add more date format support (ISO 8601, US format)
- [ ] Verbose and Quiet flags
- [ ] Cowsay option 🐮

[x] CICD for release version
## 🐛 Known Issues

[] Better cli args descriptions
- Error handling for invalid dates could be more descriptive
- Limited to Gregorian calendar only
- It will parse two-digit years as 00YY, isntead of output an error message ([chrono library issue](https://github.com/chronotope/chrono/issues/332))

[] Tests on ErrorParse
24 changes: 16 additions & 8 deletions week/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
[package]
name = "week"
version = "0.1.0"
version = "0.1.1"
edition = "2021"

rust-version = "1.70"
authors = ["Billy Tobon <billy.tobonl@gmail.com>"]
description = "Simple CLI to get the ISO week number for a given date"
repository = "https://github.com/billyto/week"
license = "MIT"
readme = "README.md"
keywords = ["cli", "date", "week", "calendar", "iso"]
categories = ["command-line-utilities", "date-and-time"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html


[dependencies]
chrono = "0.4.34"
clap = { version = "=4.4.18", features = ["derive"] }
anyhow = "1.0.80"
regex = "1.10.3"
chrono = "0.4.41"
clap = { version = "=4.5.40", features = ["derive"] }
anyhow = "1.0.98"
regex = "1.11.1"

[dev-dependencies]
assert_cmd = "2.0.14"
predicates = "3.1.0"
assert_cmd = "2.0.17"
predicates = "3.1.3"


Loading