Skip to main content

Dates for humans

Project description

human_dates
===========

I came from the Ruby/Rails world and I missed some of my date sugar. And instead of keeping complaining about it, I
thought I would do something about it


It offers two sets of functionality:

#. and foremost it has a nice `time_ago_in_words` function.
#. has some natural language for getting to the beginning and end of things

Note I stole much of this from the following StackOverflow post: http://stackoverflow.com/a/1551394/192791

Note: when you do not pass a time into a function it uses `datetime.utcnow()`


Installation
------------

.. code-block:: bash

$ pip install human_dates


time_ago_in_words Usage
-----

.. code-block:: python

from human_dates import time_ago_in_words, beginning_of_day

print time_ago_in_words()
#prints "just now"

print time_ago_in_words(beginning_of_day())
# prints 8 hours ago


Natural Language Helpers

.. code-block:: python

from human_dates import *

print beginning_of_day()
print beginning_of_hour()
print beginning_of_year()
print end_of_month()
# and so on ....

# you can also pass a datetime to each of these functions
import human_dates
from datetime import datetime
date = datetime.strptime('Feb 13 2008 1:33PM', '%b %d %Y %I:%M%p')
result = human_dates.end_of_month(date)
print result
# 2008-02-29 23:59:59.999999


Alternatives
------------

- Delorean: http://delorean.readthedocs.org/en/latest/quickstart.html (<-- please look at this before using human_dates.
It's heavyweight for me but might be great for you)

Other Important Time Libraries
- DateUtil: http://labix.org/python-dateutil
- PyTz: http://pytz.sourceforge.net/


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

human_dates-0.2.0.tar.gz (2.4 kB view details)

Uploaded Source

File details

Details for the file human_dates-0.2.0.tar.gz.

File metadata

  • Download URL: human_dates-0.2.0.tar.gz
  • Upload date:
  • Size: 2.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for human_dates-0.2.0.tar.gz
Algorithm Hash digest
SHA256 3df18daf7a47a32482f47cf42482801dc09d54908274c9ce81685dc6fe04c78c
MD5 28a32cffccff6ee9f6a9c751348cacd6
BLAKE2b-256 12f87de49a328ed53631e83a8559985ce559d90dd7f395d2a41ab83f95d76055

See more details on using hashes here.

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