A simple date helper library.
Project description
Python Package Exercise
An exercise to create a Python package, build it, test it, distribute it, and use it. See instructions for details.
datehelper
A Python utility package for date manipulation
Overview
datehelper is a Python package to help with simple date manipulation tasks. The functions included can help calculate date differences, check for weekends, and help find the date of the next requested weekday. This package can streamline date-related logic in Python projects.
Features
- days_between(date1, date2): Returns the number of days between two dates.
- add_days(date, days): Returns a new date given a date and a number of days.
- is_weekend(date): Checks if a given date is a weekend (Saturday or Sunday).
- next_weekday(date, weekday): Returns the date of the next given weekday.
Installation
pip:
pip install datehelper
- Import the functions into your code:
from datehelper import days_between, add_days, is_weekend, next_weekday
Usage Examples
next_weekday(given_date: date, weekday: int) -> date
Returns the next occurrence of a specified weekday from a given date. Weekdays are represented by integers where Monday is 0 and Sunday is 6.print(next_weekday(date(2024, 11, 4), 3))
days_between(date1: date, date2: date) -> int
Calculates the absolute number of days between two dates.print(days_between(date(2023, 1, 1), date(2023, 1, 10)))
add_days(start_date: date, days: int) -> date
Returns a new date that is a specified number of days after the given start date.print(add_days(date(2023, 1, 1), 10))
is_weekend(check_date: datetime) -> boolChecks if a given date falls on a weekend (Saturday or Sunday).print(is_weekend(datetime(2024, 11, 3)))
For a complete example, see example_date.py.
Setup
- Clone the Repository
First, clone the repository to your local machine:
git clone datehelper repository
- Next cd into where the repository folder is located on your local machine:
cd local/path/to/datehelper
- Thirdly install pipenv if you have not already using and then activate the virtual environment:
pip install pipenv
pipenv shell
- Install the dependencies
pipenv install --dev
- Build the package
python -m build
- If you have already built the package make sure to clean it:
rm -rf dist src/*.egg-info
- To run tests:
pipenv run pytest
Team Members
- Shray Awasti - Github Profile
- Toshi Troyer - Github Profile
- Ethan Cheng - Github Profile
- Joseph Hwang - Github Profile
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file datehelper_now_youre_unemployed-0.1.6.tar.gz.
File metadata
- Download URL: datehelper_now_youre_unemployed-0.1.6.tar.gz
- Upload date:
- Size: 15.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1a8574dec36d46947336d5f00d4e9cd2a4732ff4d9e43e1371f5a7be5319bc40
|
|
| MD5 |
f82feb26fad61d66879ed768c076d99f
|
|
| BLAKE2b-256 |
fbc6634cc0c71e0991b75cd64913004c31dbd4ffed87251b005cd3644f4681d2
|
File details
Details for the file datehelper_now_youre_unemployed-0.1.6-py3-none-any.whl.
File metadata
- Download URL: datehelper_now_youre_unemployed-0.1.6-py3-none-any.whl
- Upload date:
- Size: 16.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
24c70c17e9b78eb4388a7641f93d9dc3e5406873e90ae5bf489d0bd0a886409a
|
|
| MD5 |
ab52618233f18e89aa0e94294f5727c6
|
|
| BLAKE2b-256 |
d23685f48fea8b829ddf93e0995a593f31167a59614f9ca6678b52029d3c5bbc
|