https://github.com/keep94/datemath
Perform arithmetic with python datetime.date objects.
https://github.com/keep94/datemath
Last synced: 12 months ago
JSON representation
Perform arithmetic with python datetime.date objects.
- Host: GitHub
- URL: https://github.com/keep94/datemath
- Owner: keep94
- Created: 2012-11-27T16:36:10.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2012-12-01T06:22:47.000Z (over 13 years ago)
- Last Synced: 2025-06-05T11:11:37.728Z (about 1 year ago)
- Language: Python
- Size: 125 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
datemath
========
Perform arithmetic with python datetime.date objects.
# Figure out how many years, months, days from now until Christmas 2030.
import datetime
import duration
print duration.Duration.ForPeriod(
datetime.datetime.now().date(),
datetime.date(2030, 12, 25),
duration.Duration(year=1, month=1, day=1))
# Find out the next time you will be a multple of 100 weeks old.
import datetime
import duration
your_birthday = datetime.date(1990, 5, 25)
now = datetime.datetime.now().date()
dur = duration.Duration(week=100)
count = dur.Count(your_birthday, now)
print dur.AddTo(your_birthday, multiply=count + 1)