Skip to main content
Help us improve PyPI by participating in user testing. All experience levels needed!

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.

Install

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')
datetime.date(2015, 5, 17)
>>>
>>>pytime.parse('5/17/15')
datetime.date(2015, 5, 17)
>>>
>>>pytime.parse('92-11-2')
datetime.date(1992, 11, 2)

Get common festivals for single year:

>>>pytime.father()              # Father's Day
datetime.date(2015, 6, 21)
>>>
>>>pytime.mother(2016)          # 2016 Mother's Day
datetime.date(2016, 5, 8)
>>>
>>>pytime.easter(1999)          # 1999 Easter
datetime.date(1999, 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')
[datetime.date(2015, 5, 23),
 datetime.date(2015, 5, 22),
 datetime.date(2015, 5, 21),
 datetime.date(2015, 5, 20),
 datetime.date(2015, 5, 19),
 datetime.date(2015, 5, 18),
 datetime.date(2015, 5, 17)]

and other useful methods for operate datetime easily.

License

MIT

Project details


Release history Release notifications

History Node

0.2.0

History Node

0.1.8

History Node

0.1.7

History Node

0.1.6

History Node

0.1.5

History Node

0.1.3

History Node

0.1.2

This version
History Node

0.1.1

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 May 15, 2015

Supported by

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