a module to work with weekdays
Project description
A python module that provides methods to work with weekdays
Installation
$ pip install pyweekdays
Manual Installation
$ git clone https://github.com/AnishWalawalkar/weekdays.git
$ cd weekdays/
$ python setup.py install
Examples
import time
from datetime import datetime
from weekdays import weekdays
date = datetime(2016, 2, 10)
# convert time object to datetime object to work with weekdays module
weekdays.time_to_datetime(time_struct=time.gmtime()) # datetime.datetime(2016, 2, 22, 16, 42, 9)
weekdays.time_to_datetime(time_struct=time.localtime()) # datetime.datetime(2016, 2, 22, 11, 42, 39)
weekdays.time_to_datetime(time_in_seconds=time.time()) # datetime.datetime(2016, 2, 22, 11, 43, 14, 760845)
weekdays.is_weekday(date) # True
weekdays.next_weekday(date, num_days=2) # datetime.datetime(2016, 2, 12, 0, 0)
weekdays.prev_weekday(date, num_days=2) # datetime.datetime(2016, 2, 8, 0, 0)
weekdays.weekdays_until(datetime(2016,2,10), datetime(2016,2,28)) # 12.0
weekdays.weekdays_passed(datetime(2016,2,28), datetime(2016,2,10)) # 12.0
date_range = (datetime(2016, 2, 1), datetime(2016, 2, 15))
for date in weekdays.date_range(*date_range):
print(date)
# 2016-02-01 00:00:00
# 2016-02-02 00:00:00
# 2016-02-03 00:00:00
# 2016-02-04 00:00:00
# 2016-02-05 00:00:00
# 2016-02-08 00:00:00
# 2016-02-09 00:00:00
# 2016-02-10 00:00:00
# 2016-02-11 00:00:00
# 2016-02-12 00:00:00
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
pyweekdays-0.1.5.tar.gz
(2.4 kB
view hashes)