1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

osx_defaults: fix datetime

Fix #1742
This commit is contained in:
Chulki Lee 2016-04-01 17:45:33 -07:00 committed by Matt Clay
parent c8bd27f1e8
commit 432a9a31ca

View file

@ -83,7 +83,7 @@ EXAMPLES = '''
- osx_defaults: domain=com.geekchimp.macable key=ExampleKeyToRemove state=absent
'''
from datetime import datetime
import datetime
# exceptions --------------------------------------------------------------- {{{
class OSXDefaultsException(Exception):
@ -141,7 +141,7 @@ class OSXDefaults(object):
raise OSXDefaultsException("Invalid boolean value: {0}".format(repr(value)))
elif type == "date":
try:
return datetime.strptime(value.split("+")[0].strip(), "%Y-%m-%d %H:%M:%S")
return datetime.datetime.strptime(value.split("+")[0].strip(), "%Y-%m-%d %H:%M:%S")
except ValueError:
raise OSXDefaultsException(
"Invalid date value: {0}. Required format yyy-mm-dd hh:mm:ss.".format(repr(value))
@ -240,7 +240,7 @@ class OSXDefaults(object):
value = str(self.value)
elif self.array_add and self.current_value is not None:
value = list(set(self.value) - set(self.current_value))
elif isinstance(self.value, datetime):
elif isinstance(self.value, datetime.datetime):
value = self.value.strftime('%Y-%m-%d %H:%M:%S')
else:
value = self.value