Skip to main content

A utility library for working with dates and timezones

Project description

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.][https://github.com/kiraningale012/python-datetimehelper]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_datetimehelper-0.0.2-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file python_datetimehelper-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for python_datetimehelper-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1ad7bd1636d56aabd9c8e61143ad01bc17c399e4f65438532d5f309c4d3abb29
MD5 977acc38e519d6e72370bc6c12c02b75
BLAKE2b-256 10040e9a4713f1ea6d9ede291043f28434f5c72461b4b6d2f01fd8dfa411f41f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page