Skip to main content
# Easy_Date #

* https://github.com/ralphavalon/easy_date

* https://pypi.python.org/pypi/easy-date

Let's face it: there's no JodaTime for Python, and dealing with date, datetime, timestamp in Python it's not very readable or easy to understand. Easy_date can convert between str, date, datetime and timestamp easily for you and it is readable.

### Example - String to String ###

```
import easy_date

str_date = '25/12/2014' #%d/%m/%Y
new_str_date = easy_date.convert_from_string(str_date, '%d/%m/%Y', '%m-%d-%Y') # str is default return type
```

**new_str_date** will be **12-25-2014**.

### Installation ###

Install the latest stable release with:

``pip install easy_date``

or

``easy_install -U easy_date``

There are no hard dependencies other than the Python standard library.
It works with Python **2.6+** and **3.x**, but it wasn't tested on previous versions.


### How do I convert dates? ###

#### Can use two ways:

* Using **easy_date**

```
from datetime import date, datetime
import easy_date

str_date = '25/12/2014' #%d/%m/%Y

#convert_from_string(string, current_format, to_format, to_type)

new_str_date = easy_date.convert_from_string(str_date, '%d/%m/%Y', '%m-%d-%Y') # str is default return type

date_time = easy_date.convert_from_string(str_date, '%d/%m/%Y', '%Y-%m-%d', datetime)

timestamp = easy_date.convert_from_string(str_date, '%d/%m/%Y', None, float) # e.g. 1419472800.0

my_date = easy_date.convert_from_string(str_date, '%d/%m/%Y', None, date)

```


* Using **date_converter**

```
from datetime import date, datetime
import date_converter

str_date = '25/12/2014' #%d/%m/%Y

#string_to_string(string, current_format, to_format)
new_str_date = date_converter.string_to_string(str_date, '%d/%m/%Y', '%m-%d-%Y')

#string_to_datetime(string, current_format, to_format)
date_time = date_converter.string_to_datetime(str_date, '%d/%m/%Y', '%Y-%m-%d')

#string_to_timestamp(string, current_format)
timestamp = date_converter.string_to_timestamp(str_date, '%d/%m/%Y')

#string_to_date(string, current_format)
my_date = date_converter.string_to_date(str_date, '%d/%m/%Y')

```

### Available methods ###

* from **easy_date**


```
#Acceptable types: (str, datetime.datetime, datetime.date, float)
convert_from_string(string, current_format, to_format, to_type=str)

#Acceptable types: (str, datetime.datetime, datetime.date, float)
convert_from_datetime(from_datetime, to_format, to_type=str)

#Acceptable types: (str, datetime.datetime, float)
convert_from_date(from_date, to_format, to_type=str)

#Acceptable types: (str, datetime.datetime, datetime.date)
convert_from_timestamp(timestamp, to_format, to_type=str)

```


* from **date_converter**

```
#from datetime.date
date_to_datetime(from_date)
date_to_string(from_date, to_format)
date_to_timestamp(from_date)

#from datetime.datetime
datetime_to_date(from_datetime)
datetime_to_datetime(from_datetime, to_format)
datetime_to_string(from_datetime, to_format)
datetime_to_timestamp(from_datetime)

#from str
string_to_date(string, current_format)
string_to_datetime(string, current_format, to_format=None)
string_to_string(string, current_format, to_format)
string_to_timestamp(string, current_format)

#from float
timestamp_to_date(timestamp)
timestamp_to_datetime(timestamp, to_format=None)
timestamp_to_string(timestamp, to_format)

```

### Development ###

* All tests were executed using Brazil (America/Sao_Paulo) timezone. So, if you're not on this timezone and want to run tests, you can do:

```
sudo ln -fs /usr/share/zoneinfo/America/Sao_Paulo /etc/localtime
```

* You can back to your timezone using the same way.
* You can take a look on **travis_setup.sh**.

### Contribution guidelines ###

* Every help or suggestion is welcome.

### License ###

* Code and documentation are available according to the MIT License (see LICENSE.md).

Metadata

Release files for easy-date 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for easy-date 0.1.4
File Size Uploaded Provenance Actions
easy-date-0.1.4.tar.gz 3.0 kB Without provenance Details for easy-date-0.1.4.tar.gz

Release files / easy-date-0.1.4.tar.gz

Download URL easy-date-0.1.4.tar.gz
Size 3.0 kB
Tags Source
SHA-256 checksum
How to use checksums
7d77c78317d35e5775625ced2da26958474516fa703c134ae32f988aa8fac688
BLAKE2b-256 checksum
How to use checksums
f648af564a057ca1eba7e6e6744d6d9f4876798e12d7ed5de5b8b0124147206c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for easy-date 0.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page