[stable-2.9] epoch can be a float with strftime filter. Fixes #71257 (#71314). (#71320)

(cherry picked from commit 6289570234)

Co-authored-by: Matt Martz <matt@sivel.net>
pull/71527/head
Matt Martz 4 years ago committed by GitHub
parent 4a5aac0ac1
commit 48d99c0ff1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,3 @@
bugfixes:
- strftime filter - Input epoch is allowed to be a float
(https://github.com/ansible/ansible/issues/71257)

@ -107,7 +107,7 @@ def strftime(string_format, second=None):
''' return a date string using string. See https://docs.python.org/2/library/time.html#time.strftime for format ''' ''' return a date string using string. See https://docs.python.org/2/library/time.html#time.strftime for format '''
if second is not None: if second is not None:
try: try:
second = int(second) second = float(second)
except Exception: except Exception:
raise AnsibleFilterError('Invalid value for epoch value (%s)' % second) raise AnsibleFilterError('Invalid value for epoch value (%s)' % second)
return time.strftime(string_format, time.localtime(second)) return time.strftime(string_format, time.localtime(second))

Loading…
Cancel
Save