18 lines
453 B
Python
18 lines
453 B
Python
|
|
# Implementation of the @date and @datetime klammers (date.k). Each takes
|
||
|
|
# the current date and time, offset by the :days argument (positive is
|
||
|
|
# future, negative is past), and formats it.
|
||
|
|
|
||
|
|
import datetime as dt
|
||
|
|
|
||
|
|
|
||
|
|
def offset(days):
|
||
|
|
return dt.datetime.now() + dt.timedelta(days=days or 0)
|
||
|
|
|
||
|
|
|
||
|
|
def date(K):
|
||
|
|
return offset(K.days).strftime("%d %B %Y").lstrip("0")
|
||
|
|
|
||
|
|
|
||
|
|
def datetime(K):
|
||
|
|
return offset(K.days).strftime("%d %B %Y, %H:%M").lstrip("0")
|