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
- Importing the Library You can import the DateUtils class from the package and start using its methods.
Example :
from datetime_helper import DateUtils
- 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
- 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
- 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
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 Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
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 python_datetimehelper-0.0.3-py3-none-any.whl.
File metadata
- Download URL: python_datetimehelper-0.0.3-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7bd5c6dadd32a411063c9379db9bc25e5a2972bd87f117fac9373506d6d482bd
|
|
| MD5 |
bf169bb83913026836f9aab3306bc153
|
|
| BLAKE2b-256 |
25c4e2b00dc66e0eeec4dc1b6b3cd4815d18e4a4cd4094cd31f24cfa740468d2
|