Skip to main content

A easy-use module to solve the datetime needs by string

Project description

Build Status PyPI version Supported Python versions Supported Python implementations Coverage Status

PyTime is a easy-use Python module to solve the common needs of date/time/datetime.

It allows you using string to operate datetime at most situation.PyTime Also provide some simple useful method.


pip install pytime

Simple Usage

Calculate datetime all by string, accept unit for short or overall length, and they can be out of order or in capital:

>>>from pytime import pytime
>>>pytime.before('2015.5.17', '2years 3mon 3d 2hr' )     # 2years 3monhts 3days 2hours before 2015.5.17
datetime.datetime(2013, 2, 13, 22, 0)
>>>pytime.after(pytime.tomorrow(), '23month3dy29minu')   # 23months 3days 29minutes after tomorrow
datetime.datetime(2017, 4, 19, 0, 29)

Parse nonregular datetime string to datetime stamp:

>>>pytime.parse('2015517'), 5, 17)
>>>pytime.parse('5/17/15'), 5, 17)
>>>pytime.parse('92-11-2'), 11, 2)

Get common festivals for single year:

>>>pytime.father()              # Father's Day, 6, 21)
>>>pytime.mother(2016)          # 2016 Mother's Day, 5, 8)
>>>pytime.easter(1999)          # 1999 Easter, 4, 4)

Pytime support calculate between date and datetime, but set the date to midnight:

>>>pytime.count('2015-5-17 23:23:23', pytime.tomorrow())
datetime.timedelta(1, 84203)

Get days between two date, count timedelta by string.

>>>pytime.daysrange('2015-5-17', '2015-5-23')
[, 5, 23),, 5, 22),, 5, 21),, 5, 20),, 5, 19),, 5, 18),, 5, 17)]

and other useful methods for operate datetime easily.



Project details

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
pytime-0.1.1.tar.gz (6.4 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page