Skip to main content

A handy python function to parse and convert to and between datetime.datetime, int, and string objects

Project description

Date Converter

A handy date parser and converter that handles timestamps, strings, and datetime.date.

Convert from any date to another with a single function!

Date converter will make your naive dates timezone aware and uniformly convert them to UTC for your convenience!

Basic Use

from date_to import date_to

some_date = "2001-09-11 17:20 EDT"

date_to(some_date, str)
date_to(some_date, int)
date_to(some_date, "datetime")

print(type(a), a)
print(type(b), b)
print(type(c), c)

Output:

<class 'str'> "2001-09-11T21:20:00+00:00"
<class 'int'> 1000243200
<class 'datetime.datetime'> 2001-09-11 21:20:00+00:00

Accepted Inputs

from datetime import datetime

accepted_object_inputs = int | str | datetime.date
accepted_string_inputs = [
    "str", "string",
    "int", "timestamp", "epoch", "unix", "float",
    "datetime.date", "datetime", "date",
]

Project details


Download files

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

Source Distribution

date_to-1.0a2.tar.gz (11.6 kB view hashes)

Uploaded Source

Built Distribution

date_to-1.0a2-py3-none-any.whl (3.7 kB view hashes)

Uploaded Python 3

Supported by

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