dayspan


Namedayspan JSON
Version 1.0.10 PyPI version JSON
download
home_pageNone
SummaryA simple tool to count days between two dates (YYYYMMDD).
upload_time2025-08-15 18:14:54
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseNone
keywords date time span datetime period
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # DaySpan

[![PyPI](https://img.shields.io/pypi/v/dayspan?color=%232EA51B&cacheSeconds=300)](https://pypi.org/project/dayspan/)
[![Python Support](https://img.shields.io/pypi/pyversions/dayspan.svg)](https://pypi.org/project/dayspan/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

A simple Python package to calculate the number of days between two dates (inclusive).

## Features

- Calculate days between two dates, including both start and end dates
- Simple command-line interface
- Cross-platform support (Linux, macOS, Windows)
- No external dependencies - uses only Python standard library
- Clear output indicating inclusive calculation
- Support for dates from year 1 to 9999

## Installation

### From PyPI

```bash
pip install dayspan
```

### From GitHub

```bash
pip install git+https://github.com/YOUR_USERNAME/dayspan.git
```

### From source

```bash
git clone https://github.com/YOUR_USERNAME/dayspan.git
cd dayspan
pip install .
```

### For development

```bash
git clone https://github.com/YOUR_USERNAME/dayspan.git
cd dayspan
pip install -e .
```

## Usage

### Command Line Interface

Basic usage:
```bash
dayspan 20250101 20251231
```

Output:
```
365 days (from 2025-01-01 to 2025-12-31, inclusive)
```

Verbose output:
```bash
dayspan -v 20250101 20251231
```

Output:
```
Start date: 2025-01-01
End date: 2025-12-31
Days from 2025-01-01 to 2025-12-31 (inclusive): 365 days
```

Help:
```bash
dayspan -h
```

Version:
```bash
dayspan --version
```

### Python API

```python
from dayspan import calculate_days

# Calculate days between two dates
days, start_formatted, end_formatted = calculate_days("20250101", "20251231")
print(f"{days} days from {start_formatted} to {end_formatted}")
# Output: 365 days from 2025-01-01 to 2025-12-31

# Parse individual dates
from dayspan import parse_date
date = parse_date("20250101")
print(date)  # 2025-01-01 00:00:00
```

## Examples

### Days in a month
```bash
dayspan 20250301 20250331
# Output: 31 days (from 2025-03-01 to 2025-03-31, inclusive)
```

### Days in a leap year
```bash
dayspan 20240101 20241231
# Output: 366 days (from 2024-01-01 to 2024-12-31, inclusive)
```

### Days between two specific dates
```bash
dayspan 19930101 20241231
# Output: 11687 days (from 1993-01-01 to 2024-12-31, inclusive)
```

### Single day
```bash
dayspan 20250101 20250101
# Output: 1 days (from 2025-01-01 to 2025-01-01, inclusive)
```

### Leap year February
```bash
dayspan 20240201 20240229
# Output: 29 days (from 2024-02-01 to 2024-02-29, inclusive)
```

## Why Inclusive?

DaySpan counts both the start and end dates, which is the intuitive way most people think about date ranges:

- From January 1 to January 31 = 31 days (the entire month)
- From Monday to Friday = 5 days (the work week)
- From today to today = 1 day (not 0)

This matches how we naturally count days on a calendar.

## Input Format

- Dates must be in `YYYYMMDD` format
- Year: 0001-9999
- Month: 01-12
- Day: 01-31 (validated according to month and year)

## Error Handling

The tool validates input dates and provides clear error messages:

```bash
# Invalid date format
dayspan 2025-01-01 2025-12-31
# Error: Invalid date format: '2025-01-01'. Expected YYYYMMDD format.

# End date before start date
dayspan 20251231 20250101
# Error: End date (20250101) must be after or equal to start date (20251231)

# Invalid date
dayspan 20250132 20251231
# Error: Invalid date: '20250132'. day is out of range for month
```

## Requirements

- Python 3.9 or higher
- No external dependencies

## Development

### Running Tests

```bash
# Option A
python test_dayspan.py

# Option B
pytest test_dayspan.py
```

### Building from Source

```bash
# Install build tools
pip install build

# Build distributions
python -m build
```

## Contributing

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

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request

## License

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

## Author

Cong Gao - [cnggao@gmail.com](mailto:cnggao@gmail.com)

## Acknowledgments

- Thanks to all contributors who have helped with this project
- Inspired by the need for a simple, reliable day calculation tool

## Changelog

### v1.0.10 (2025-08-15)
- release

### v1.0.10a1 (2025-08-15)
- v1.0.10d is not valid

### v1.0.10d (2025-08-15)
- mkdir tests and mv the test into tests/

### v1.0.10c (2025-08-15)
- exclude python 3.8 (the package does work for 
python 3.8 but the .toml does not work for python 3.8)

### v1.0.10b (2025-08-15)
- include python version test

### v1.0.10a (2025-08-15)
- keep github repo clean

### v1.0.9 (2025-08-15)
- published automatically by github action

### v1.0.8 (2025-08-13)
- update the python requirement

### v1.0.7 (2025-08-13)
- version controled unified in .toml

### v1.0.6 (2025-08-13)
- debug the version in command-line

### v1.0.5 (2025-08-12)
- update the pip badge

### v1.0.4 (2025-08-12)
- builded by .toml instead of setup.py

### v1.0.3 (2025-07-03)
- Initial release
- Basic day calculation functionality
- Command-line interface
- Python API
- Cross-platform support

---

If you find this tool useful, please consider giving it a star on [GitHub](https://github.com/CongGao-CG/dayspan)!

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "dayspan",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "Cong Gao <cnggao@gmail.com>",
    "keywords": "date, time, span, datetime, period",
    "author": null,
    "author_email": "Cong Gao <cnggao@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/2e/5e/4bc6d945dc4b526d410fae4880b42521fd0b1c967dca9474bbb9122f3fd1/dayspan-1.0.10.tar.gz",
    "platform": null,
    "description": "# DaySpan\n\n[![PyPI](https://img.shields.io/pypi/v/dayspan?color=%232EA51B&cacheSeconds=300)](https://pypi.org/project/dayspan/)\n[![Python Support](https://img.shields.io/pypi/pyversions/dayspan.svg)](https://pypi.org/project/dayspan/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nA simple Python package to calculate the number of days between two dates (inclusive).\n\n## Features\n\n- Calculate days between two dates, including both start and end dates\n- Simple command-line interface\n- Cross-platform support (Linux, macOS, Windows)\n- No external dependencies - uses only Python standard library\n- Clear output indicating inclusive calculation\n- Support for dates from year 1 to 9999\n\n## Installation\n\n### From PyPI\n\n```bash\npip install dayspan\n```\n\n### From GitHub\n\n```bash\npip install git+https://github.com/YOUR_USERNAME/dayspan.git\n```\n\n### From source\n\n```bash\ngit clone https://github.com/YOUR_USERNAME/dayspan.git\ncd dayspan\npip install .\n```\n\n### For development\n\n```bash\ngit clone https://github.com/YOUR_USERNAME/dayspan.git\ncd dayspan\npip install -e .\n```\n\n## Usage\n\n### Command Line Interface\n\nBasic usage:\n```bash\ndayspan 20250101 20251231\n```\n\nOutput:\n```\n365 days (from 2025-01-01 to 2025-12-31, inclusive)\n```\n\nVerbose output:\n```bash\ndayspan -v 20250101 20251231\n```\n\nOutput:\n```\nStart date: 2025-01-01\nEnd date: 2025-12-31\nDays from 2025-01-01 to 2025-12-31 (inclusive): 365 days\n```\n\nHelp:\n```bash\ndayspan -h\n```\n\nVersion:\n```bash\ndayspan --version\n```\n\n### Python API\n\n```python\nfrom dayspan import calculate_days\n\n# Calculate days between two dates\ndays, start_formatted, end_formatted = calculate_days(\"20250101\", \"20251231\")\nprint(f\"{days} days from {start_formatted} to {end_formatted}\")\n# Output: 365 days from 2025-01-01 to 2025-12-31\n\n# Parse individual dates\nfrom dayspan import parse_date\ndate = parse_date(\"20250101\")\nprint(date)  # 2025-01-01 00:00:00\n```\n\n## Examples\n\n### Days in a month\n```bash\ndayspan 20250301 20250331\n# Output: 31 days (from 2025-03-01 to 2025-03-31, inclusive)\n```\n\n### Days in a leap year\n```bash\ndayspan 20240101 20241231\n# Output: 366 days (from 2024-01-01 to 2024-12-31, inclusive)\n```\n\n### Days between two specific dates\n```bash\ndayspan 19930101 20241231\n# Output: 11687 days (from 1993-01-01 to 2024-12-31, inclusive)\n```\n\n### Single day\n```bash\ndayspan 20250101 20250101\n# Output: 1 days (from 2025-01-01 to 2025-01-01, inclusive)\n```\n\n### Leap year February\n```bash\ndayspan 20240201 20240229\n# Output: 29 days (from 2024-02-01 to 2024-02-29, inclusive)\n```\n\n## Why Inclusive?\n\nDaySpan counts both the start and end dates, which is the intuitive way most people think about date ranges:\n\n- From January 1 to January 31 = 31 days (the entire month)\n- From Monday to Friday = 5 days (the work week)\n- From today to today = 1 day (not 0)\n\nThis matches how we naturally count days on a calendar.\n\n## Input Format\n\n- Dates must be in `YYYYMMDD` format\n- Year: 0001-9999\n- Month: 01-12\n- Day: 01-31 (validated according to month and year)\n\n## Error Handling\n\nThe tool validates input dates and provides clear error messages:\n\n```bash\n# Invalid date format\ndayspan 2025-01-01 2025-12-31\n# Error: Invalid date format: '2025-01-01'. Expected YYYYMMDD format.\n\n# End date before start date\ndayspan 20251231 20250101\n# Error: End date (20250101) must be after or equal to start date (20251231)\n\n# Invalid date\ndayspan 20250132 20251231\n# Error: Invalid date: '20250132'. day is out of range for month\n```\n\n## Requirements\n\n- Python 3.9 or higher\n- No external dependencies\n\n## Development\n\n### Running Tests\n\n```bash\n# Option A\npython test_dayspan.py\n\n# Option B\npytest test_dayspan.py\n```\n\n### Building from Source\n\n```bash\n# Install build tools\npip install build\n\n# Build distributions\npython -m build\n```\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/AmazingFeature`)\n3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)\n4. Push to the branch (`git push origin feature/AmazingFeature`)\n5. Open a Pull Request\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Author\n\nCong Gao - [cnggao@gmail.com](mailto:cnggao@gmail.com)\n\n## Acknowledgments\n\n- Thanks to all contributors who have helped with this project\n- Inspired by the need for a simple, reliable day calculation tool\n\n## Changelog\n\n### v1.0.10 (2025-08-15)\n- release\n\n### v1.0.10a1 (2025-08-15)\n- v1.0.10d is not valid\n\n### v1.0.10d (2025-08-15)\n- mkdir tests and mv the test into tests/\n\n### v1.0.10c (2025-08-15)\n- exclude python 3.8 (the package does work for \npython 3.8 but the .toml does not work for python 3.8)\n\n### v1.0.10b (2025-08-15)\n- include python version test\n\n### v1.0.10a (2025-08-15)\n- keep github repo clean\n\n### v1.0.9 (2025-08-15)\n- published automatically by github action\n\n### v1.0.8 (2025-08-13)\n- update the python requirement\n\n### v1.0.7 (2025-08-13)\n- version controled unified in .toml\n\n### v1.0.6 (2025-08-13)\n- debug the version in command-line\n\n### v1.0.5 (2025-08-12)\n- update the pip badge\n\n### v1.0.4 (2025-08-12)\n- builded by .toml instead of setup.py\n\n### v1.0.3 (2025-07-03)\n- Initial release\n- Basic day calculation functionality\n- Command-line interface\n- Python API\n- Cross-platform support\n\n---\n\nIf you find this tool useful, please consider giving it a star on [GitHub](https://github.com/CongGao-CG/dayspan)!\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A simple tool to count days between two dates (YYYYMMDD).",
    "version": "1.0.10",
    "project_urls": {
        "Documentation": "https://github.com/CongGao-CG/dayspan#readme",
        "Homepage": "https://github.com/CongGao-CG/dayspan",
        "Issues": "https://github.com/CongGao-CG/dayspan/issues",
        "Repository": "https://github.com/CongGao-CG/dayspan.git"
    },
    "split_keywords": [
        "date",
        " time",
        " span",
        " datetime",
        " period"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "c53038762af47368fb9f2d4063d75438e2b2b46ef42755526ad82366a9897716",
                "md5": "a426a1c3014d5b03f8ec4844cd683a61",
                "sha256": "2814cbb66214c4c269d683a9c7f2c47ffae2398abcf271704b0309fecddd620d"
            },
            "downloads": -1,
            "filename": "dayspan-1.0.10-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a426a1c3014d5b03f8ec4844cd683a61",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 6424,
            "upload_time": "2025-08-15T18:14:53",
            "upload_time_iso_8601": "2025-08-15T18:14:53.584847Z",
            "url": "https://files.pythonhosted.org/packages/c5/30/38762af47368fb9f2d4063d75438e2b2b46ef42755526ad82366a9897716/dayspan-1.0.10-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "2e5e4bc6d945dc4b526d410fae4880b42521fd0b1c967dca9474bbb9122f3fd1",
                "md5": "652d2abb5dc74f2034b4e8d8f4fd2256",
                "sha256": "9caa30202b7837b89bdc847442cafcfb6c2852e726b9e50cf6634abc1e697769"
            },
            "downloads": -1,
            "filename": "dayspan-1.0.10.tar.gz",
            "has_sig": false,
            "md5_digest": "652d2abb5dc74f2034b4e8d8f4fd2256",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 5989,
            "upload_time": "2025-08-15T18:14:54",
            "upload_time_iso_8601": "2025-08-15T18:14:54.295913Z",
            "url": "https://files.pythonhosted.org/packages/2e/5e/4bc6d945dc4b526d410fae4880b42521fd0b1c967dca9474bbb9122f3fd1/dayspan-1.0.10.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-15 18:14:54",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "CongGao-CG",
    "github_project": "dayspan#readme",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "dayspan"
}
        
Elapsed time: 0.40487s