2

I'm writing a Python function/class/module/gizmo to convert the following values to YYYY-MM-DD. I'm begrudgingly willing to accept employing the non-standard dateutil to enable easier implementation.

I'm not expecting the stackoverflow community to simply "write this whole thing for me," and I'll probably answer my own question when done. Along the way, any pointers are greatly appreciated. I haven't yet found a Q+A discussion that comprehensively addresses my needs below, but of course I'll be borrowing from those that address portions. eg: "find Monday's" and "timedelta in years" and "six months out".

Additionally: if there's an existing, mature, library (even if it's a non-standard library) that handles some/more/all of this, it might save me significant work. Thanks for any help.

case-insensitive match and conversion of any of the following to YYYY-MM-DD
    today
    tomorrow
    yesterday
    monday     = next monday
    tuesday    = next tuesday
    wednesday  = next wednesday
    thursday   = next thursday
    friday     = next friday
    saturday   = next saturday
    sunday     = next sunday
    -monday    = last monday
    -tuesday   = last tuesday
    -wednesday = last wednesday
    -thursday  = last thursday
    -friday    = last friday
    -saturday  = last saturday
    -sunday    = last sunday
    x[d|w|m|y]  = 'x' number of days/weeks/months/years in future
    -x[d|w|m|y] = 'x' number of days/weeks/months/years in past
    examples
        1d  = 1 day from today
        2w  = 2 weeks from today
        3m  = 3 months from today
        4y  = 4 years from  today
        -4d = 4 days ago
        -3w = 3 weeks ago
        -2m = 2 months ago
        -1y = 1 year ago
 unique truncations of today, tomorrow, yesterday, and
 days of week (monday, tuesday) are matched with their 
 expanded values.  eg: 'mo', '-Tues', 'tom', 'yest', 'tod'
Community
  • 1
  • 1
Johnny Utahh
  • 2,389
  • 3
  • 25
  • 41
  • This question ( http://stackoverflow.com/questions/1495487/is-there-any-python-library-for-parsing-dates-and-times-from-a-natural-language ) offers a library that looks quite powerful. – Luke May 13 '15 at 04:03
  • Thanks @Luke. parsedatetime does indeed serve what I need, although version 1.4 still has some inconsistencies, but still quite useable. Details [here](http://stackoverflow.com/a/30224711/605356). – Johnny Utahh May 14 '15 at 19:24

0 Answers0