New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

python-datetimehelper

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

python-datetimehelper

A utility library for working with dates and timezones

  • 0.0.3
  • PyPI
  • Socket score

Maintainers
1

DateUtils Library

Description

A Python python-datetimehelper library for working with dates, time formatting, and timezone conversions.

Installation

pip install python-datetimehelper

Usage

  1. Importing the Library You can import the DateUtils class from the package and start using its methods.

Example :

from datetime_helper import DateUtils

  1. Formatting Dates The format_date method allows you to format a datetime object or an ISO 8601 string into a custom date format.

Example :

from datetime import datetime
from datetime_helper import DateUtils

date_input = datetime(2024, 11, 20, 14, 30, 00)
formatted_date = DateUtils.format_date(date_input, 'dd-MM-yyyy HH:mm:ss')
print(formatted_date)  # Output: 20-11-2024 14:30:00
  1. Converting Timezones The convert_timezone method enables you to convert a datetime object from one timezone to another.

Example :


from datetime_helper import DateUtils
from datetime import datetime

date_input = datetime(2024, 11, 20, 14, 30, 00)
converted_date = DateUtils.convert_timezone(date_input, 'UTC', 'Asia/Kolkata')
print(converted_date)  # Output: 2024-11-20 20:00:00+05:30

  1. Adding Time You can add or subtract time (days, hours, minutes, etc.) to a datetime object using the add_time method.

Example:


from datetime_helper import DateUtils
from datetime import datetime

date_input = datetime(2024, 11, 20, 14, 30, 00)
new_date = DateUtils.add_time(date_input, days=2, hours=5)
print(new_date)  # Output: 2024-11-22 19:30:00

Documentation

For more detailed usage and additional features, refer to the documentation on GitHub.

Sources and References

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