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.

Sources and References

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.3-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for python_datetimehelper-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7bd5c6dadd32a411063c9379db9bc25e5a2972bd87f117fac9373506d6d482bd
MD5 bf169bb83913026836f9aab3306bc153
BLAKE2b-256 25c4e2b00dc66e0eeec4dc1b6b3cd4815d18e4a4cd4094cd31f24cfa740468d2

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