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
file: add doc on how to convert epoch seconds to datetime #53357
Conversation
file: | ||
path: /etc/another_file | ||
state: file | ||
access_time: '{{ "%Y%m%d%H%M.%S" | strftime(stat_var.stat.atime) }}' |
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.
I don't think your strftime template is correct
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.
Hmm it worked for me, what part do you think isn't correct?
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.
i always used '%s' .. won't the above print yearmonthdayhourminute. seconds?
also i think we did strftime wrong, i would expect dateortime|strftime('format')
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.
@jborean93 i think you are doing the opposite transformation, you are turning 'seconds/epoch' into a date string
nvmd, its opposite of what user wanted to implement, but how we can get 'epoch' to work with current module ... took me a bit to square the circle .. moving on ... nothing to see...
In this way it is not possible to set the time with greater accuracy than a second. The strftime filter returns values with an accuracy of one second. The os.utime function is able to set the time with an accuracy of microseconds. My previous patch allowed just such modifications. |
SUMMARY
Add an example of how to convert a stat time output, or seconds since epoch to the datetime format expected by the file module.
ISSUE TYPE
COMPONENT NAME
file