Skip to main content

UNKNOWN

Project description

DerpTime helps you to calculate deifferences between datetimes while excluding weekends (calculating with workdays only).

Typical usage:

#!/usr/bin/env python

from derptime import WorkingHoursDateTime
from datetime import datetime, timedelta

whdt = WorkingHoursDateTime(2013,11,11,10,10)

if (whdt - timedelta(hours=24)) > datetime.now():
    print "We still have some time before the deadline!"

Usage

Adding timedelta objects::

>>> from derptime import WorkingHoursDateTime
>>> from datetime import timedelta
>>>
>>> WorkingHoursDateTime(2013,11,8,10,10) + timedelta(hours=24)
WorkingHoursDateTime(2013, 11, 11, 10, 10)

Subtracting timedelta objects::

>>> from derptime import WorkingHoursDateTime
>>> from datetime import timedelta
>>>
>>> WorkingHoursDateTime(2013,11,11,10,10) - timedelta(hours=24)
WorkingHoursDateTime(2013, 11, 8, 10, 10)

Subtracting WorkingHoursDateTime and/or datetime objects::

>>> from derptime import WorkingHoursDateTime
>>> from datetime import datetime, timedelta
>>>
>>> WorkingHoursDateTime(2013,11,11,10,10) - WorkingHoursDateTime(2013,11,8,10,10)
datetime.timedelta(1)
>>>
>>> WorkingHoursDateTime(2013,11,11,10,10) - datetime(2013,11,8,10,10)
datetime.timedelta(1)

Convert from datetime::

>>> from derptime import WorkingHoursDateTime
>>> from datetime import datetime
>>>
>>> WorkingHoursDateTime.from_datetime(datetime(2013,11,8,10,10))
WorkingHoursDateTime(2013, 11, 8, 10, 10)

Convert to datetime::

>>> from derptime import WorkingHoursDateTime
>>> from datetime import datetime
>>>
>>> WorkingHoursDateTime(2013,11,11,10,10).to_datetime()
datetime.datetime(2013, 11, 11, 10, 10)

Using now::

>>> from derptime import WorkingHoursDateTime
>>>
>>> # You can still use the good-old "new" classmethod the same way
>>> WorkingHoursDateTime.now()
WorkingHoursDateTime(2013, 11, 8, 16, 29, 28, 977699)

Project details


Download files

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

Files for DerpTime, version 0.1
Filename, size File type Python version Upload date Hashes
Filename, size DerpTime-0.1.tar.gz (2.9 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page