Added to_datetime filter (#17145)

* Added to_datetime filter

* Added to_datetime filter documentation
This commit is contained in:
Roman Belyakovsky
2016-09-01 03:51:03 +04:00
committed by Michael Scherer
parent 2ffb136b3f
commit d80d986a38
2 changed files with 14 additions and 3 deletions

View File

@@ -34,6 +34,7 @@ import hashlib
import string
from functools import partial
from random import SystemRandom, shuffle
from datetime import datetime
import uuid
import yaml
@@ -116,6 +117,10 @@ def to_bool(a):
else:
return False
def to_datetime(string, format="%Y-%d-%m %H:%M:%S"):
return datetime.strptime(string, format)
def quote(a):
''' return its argument quoted for shell usage '''
return pipes.quote(a)
@@ -393,6 +398,9 @@ class FilterModule(object):
'to_nice_yaml': to_nice_yaml,
'from_yaml': yaml.safe_load,
#date
'to_datetime': to_datetime,
# path
'basename': partial(unicode_wrap, os.path.basename),
'dirname': partial(unicode_wrap, os.path.dirname),