-
Notifications
You must be signed in to change notification settings - Fork 23.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add epoch_int in date_time facts #73822
Conversation
ready_for_review |
@@ -49,6 +49,9 @@ def collect(self, module=None, collected_facts=None): | |||
date_time_facts['epoch'] = now.strftime('%s') | |||
if date_time_facts['epoch'] == '' or date_time_facts['epoch'][0] == '%': | |||
date_time_facts['epoch'] = str(int(epoch_ts)) | |||
date_time_facts['epoch_int'] = str(int(now.strftime('%s'))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a comment explaining why this is different from the existing epoch value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR and ansible-collections/ansible.windows#123 were created because of this issue: #72479
Current epoch
value returns float and string in some circumstances, epoch_int
is guaranteed to be integer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I should have been more specific. Can you add a comment to the code explaining the possibility of the current epoch being a float? That will help anyone in the future looking at the code, since it's otherwise not obvious why we need both epoch and epoch_int.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in d2c161d.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. This PR is assigned to the 2.12 milestone, which we'll be going through after creating the stable-2.11 branch (which will be done when 2.11 RC1 comes out).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for reviewing!
SUMMARY
Add
epoch_int
to setup facts which always returns epoch as an integer.ISSUE TYPE
COMPONENT NAME
lib/ansible/module_utils/facts/system/date_time.py
ADDITIONAL INFORMATION
Previously opened in #72503.