This is the first time I'm attempting a markdown page in vim. There's some fun stuff, like python syntax highlighting. I'll take the opportunity to record some very simple date functions I find handy.

from datetime import datetime, date, timedelta
import re

def now(): return datetime.now()

def today(): return date.today()

def yesterday():
    return today() + timedelta(-1)

def vorgestern():
    return today() + timedelta(-2)

def tomorrow():
    return today() + timedelta(1)

def lastweek(w=1):
    return today() - timedelta(7*w)

def firstofmonth(t=0):
    '''Provides a date object adjusted by d months with first of month.
    Defaults to first of current month.'''
    m = today().month
    new_m = (m+t) % 12 if (m+t) % 12 != 0 else 12
    y = today().year
    new_y = y+(t/12)+1 if (12-t % 12) < m else y+(t/12)
    return date(new_y, new_m, 1)

def lastofmonth(t=0):
    '''Provides a date object adjusted by d months with last day of that
    month. Defaults to last of current month.'''
    return firstofmonth(t+1) + timedelta(-1)

def guess_datetime(t, filename=False):
    '''Returns either datetime object from string, or None if failure'''
    l = len(t.strip())
    if filename:
        # strip out all extraneous chars and look for date.
        t = ''.join(re.findall(r"[0-9]+", t))
        l = len(t)
    if l in [10, 19, 26]:
        # Presume ISO Format timestamp YYYY-MM-DDTHH:MM:SS or YYYY-MM-DD
        try:
            timestamp = datetime(*[int(n) for n in re.findall(r"[0-9]+", t)])
        except:
            timestamp = None
    elif l == 20 and t[-1] == 'Z':
        # Presume ISO Format timestamp YYYY-MM-DDTHH:MM:SSZ
        try:
            timestamp = datetime(*[int(n) for n in re.findall(r"[0-9]+", t)])
        except:
            timestamp = None
    elif l == 14:
        # Presume GPS Format timestamp YYYYMMDDHHMMSS
        try:
            timestamp = datetime.strptime(t, '%Y%m%d%H%M%S')
        except:
            timestamp = None
    elif l == 8:
        # Presume GPS Format datestamp YYYYMMDD
        try:
            timestamp = datetime.strptime(t, '%Y%m%d')
        except:
            timestamp = None
    else:
        timestamp = None
    return timestamp