Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

datehelper-now-youre-unemployed

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

datehelper-now-youre-unemployed

A simple date helper library.

  • 0.1.6
  • PyPI
  • Socket score

Maintainers
1

Python Package Exercise

An exercise to create a Python package, build it, test it, distribute it, and use it. See instructions for details.

datehelper

Event Logger Workflow

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

  1. pip:

pip install datehelper

  1. Import the functions into your code:

from datehelper import days_between, add_days, is_weekend, next_weekday


Usage Examples

  1. 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))
    
    
  2. 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)))
    
    
    
  3. 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))
    
    
  4. is_weekend(check_date: datetime) -> bool Checks 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

  1. Clone the Repository

First, clone the repository to your local machine:

git clone datehelper repository 
  1. Next cd into where the repository folder is located on your local machine:
cd local/path/to/datehelper
  1. Thirdly install pipenv if you have not already using and then activate the virtual environment:
pip install pipenv 
pipenv shell
  1. Install the dependencies
pipenv install --dev
  1. Build the package
python -m build
  1. If you have already built the package make sure to clean it:
rm -rf dist src/*.egg-info
  1. To run tests:
pipenv run pytest

Team Members


FAQs


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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc