parsetime update

I’ve just got done with a large refactoring of my time parsing code. I’ve moved all of the routines into a class (currently named Calendar for lack of a better name) and also moved all of the constants into their own class. The idea is that the CalendarConstants class can be derived from for different translations and then passed to the init method of the Calendar class.

I’ve also added an Inc(date, day, month, year) function that takes the given date (or the current day if None) and adds onto it the given days, months and/or years. It adjusts the number of days to handle the different days in each month and also handles leap years.

I really need to find some sample Python code to compare how I’ve done certain class implementation details to make sure I’m not really borking something.

This is the output from the latest testing run – I have to find out why “next wednesday” has started failing :(

True 5 minutes from now
True 5 min from now
True 5m from now
True in 5 minutes
True 5 min
True 5 min before now
True 5 min before next week
True 5 hours from noon
True 5 hours before noon
True in 2 weeks
True 7 days before now
True next day
True next week
True last week
False next wednesday
(2004, 12, 15, 3, 15, 47, 2, 350, 0)
(2004, 12, 14, 3, 15, 48, 1, 349, 0)
True next friday
True Inc(month=4) from Jan 1, 2004
True Inc(month=12) from Jan 1, 2004
True Inc(month=14) from Jan 1, 2004

“parsetime.py”:http://code-bear.com:4200/svn/codebear/timeparse/branches/parsetime.py
“parsetime_consts.py”:http://code-bear.com:4200/svn/codebear/timeparse/branches/parsetime_consts.py

pretty nifty stuff if I do say so myself


Tags:

 
 
 

Comments are closed.