From b5a5211cd410d642d65976ac399b12502a1ded6c Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Tue, 24 Apr 2018 11:11:46 -0400 Subject: [PATCH] remove slice docs (#37946) (cherry picked from commit b533ebe20d274d3d7d1acb0dafa6affe54f69f8b) backport of #37946 --- changelogs/fragments/remove_slice_docs.yml | 2 ++ .../rst/user_guide/playbooks_filters.rst | 21 +++++++------------ 2 files changed, 10 insertions(+), 13 deletions(-) create mode 100644 changelogs/fragments/remove_slice_docs.yml diff --git a/changelogs/fragments/remove_slice_docs.yml b/changelogs/fragments/remove_slice_docs.yml new file mode 100644 index 00000000000..d50040ae8c9 --- /dev/null +++ b/changelogs/fragments/remove_slice_docs.yml @@ -0,0 +1,2 @@ +bugfixes: + - filter was removed ... docs shoudl be too https://github.com/ansible/ansible/pull/37946 diff --git a/docs/docsite/rst/user_guide/playbooks_filters.rst b/docs/docsite/rst/user_guide/playbooks_filters.rst index 84049aceaa2..247130fc3cb 100644 --- a/docs/docsite/rst/user_guide/playbooks_filters.rst +++ b/docs/docsite/rst/user_guide/playbooks_filters.rst @@ -922,22 +922,17 @@ To make use of one attribute from each item in a list of complex variables, use # get a comma-separated list of the mount points (e.g. "/,/mnt/stuff") on a host {{ ansible_mounts|map(attribute='mount')|join(',') }} -.. versionadded:: 2.5 - -The `slice` filter can be used to extract the values of specific keys from a -hash:: - - {{ {'x': 1, 'y': 2, 'z': 3 } | slice(['x', 'z']) }} - -This will result in:: - - [1, 2] - To get date object from string use the `to_datetime` filter, (new in version in 2.2):: - # get amount of seconds between two dates, default date format is %Y-%m-%d %H:%M:%S but you can pass your own one - {{ (("2016-08-14 20:00:12"|to_datetime) - ("2015-12-25"|to_datetime('%Y-%m-%d'))).seconds }} + # Get total amount of seconds between two dates. Default date format is %Y-%m-%d %H:%M:%S but you can pass your own format + {{ (("2016-08-14 20:00:12"|to_datetime) - ("2015-12-25"|to_datetime('%Y-%m-%d'))).total_seconds() }} + + # Get remaining seconds after delta has been calculated. NOTE: This does NOT convert years, days, hours, etc to seconds. For that, use total_seconds() + {{ (("2016-08-14 20:00:12"|to_datetime) - ("2016-08-14 18:00:00"|to_datetime)).seconds }} + # This expression evaluates to "12" and not "132". Delta is 2 hours, 12 seconds + # get amount of days between two dates. This returns only number of days and discards remaining hours, minutes, and seconds + {{ (("2016-08-14 20:00:12"|to_datetime) - ("2015-12-25"|to_datetime('%Y-%m-%d'))).days }} Combination Filters ````````````````````