parent
cf86c6aaf6
commit
bfb5264138
1 changed files with 4 additions and 2 deletions
|
@ -35,7 +35,7 @@ import uuid
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
from collections import MutableMapping, MutableSequence
|
from collections import MutableMapping, MutableSequence
|
||||||
from datetime import datetime
|
import datetime
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from random import Random, SystemRandom, shuffle
|
from random import Random, SystemRandom, shuffle
|
||||||
|
|
||||||
|
@ -69,6 +69,8 @@ class AnsibleJSONEncoder(json.JSONEncoder):
|
||||||
def default(self, o):
|
def default(self, o):
|
||||||
if isinstance(o, HostVars):
|
if isinstance(o, HostVars):
|
||||||
return dict(o)
|
return dict(o)
|
||||||
|
elif isinstance(o, (datetime.date, datetime.datetime)):
|
||||||
|
return o.isoformat()
|
||||||
else:
|
else:
|
||||||
return super(AnsibleJSONEncoder, self).default(o)
|
return super(AnsibleJSONEncoder, self).default(o)
|
||||||
|
|
||||||
|
@ -126,7 +128,7 @@ def to_bool(a):
|
||||||
|
|
||||||
|
|
||||||
def to_datetime(string, format="%Y-%m-%d %H:%M:%S"):
|
def to_datetime(string, format="%Y-%m-%d %H:%M:%S"):
|
||||||
return datetime.strptime(string, format)
|
return datetime.datetime.strptime(string, format)
|
||||||
|
|
||||||
|
|
||||||
def strftime(string_format, second=None):
|
def strftime(string_format, second=None):
|
||||||
|
|
Loading…
Reference in a new issue