1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/plugins/filter/to_time_unit.yml
Felix Fontein 011b2f8bdc
Start using semantic markup (#6627)
* Start using semantic markup.

* Forgot some places.

* Fix typo.

* Use 'ignore:' prefix until https://github.com/ansible-community/antsibull-docs/pull/155 is out.

* Break too long line.
2023-06-10 09:28:40 +02:00

89 lines
2.3 KiB
YAML

---
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
DOCUMENTATION:
name: to_time_unit
short_description: Converte a duration string to the given time unit
version_added: 0.2.0
description:
- Parse a human readable time duration string and convert to the given time unit.
positional: unit
options:
_input:
description:
- The time string to convert.
- Can use the units V(y) and V(year) for a year, V(mo) and V(month) for a month, V(w) and V(week) for a week,
V(d) and V(day) for a day, V(h) and V(hour) for a hour, V(m), V(min) and V(minute) for minutes, V(s), V(sec)
and V(second) for seconds, V(ms), V(msec), V(msecond) and V(millisecond) for milliseconds. The suffix V(s)
can be added to a unit as well, so V(seconds) is the same as V(second).
- Valid strings are space separated combinations of an integer with an optional minus sign and a unit.
- Examples are V(1h), V(-5m), and V(3h -5m 6s).
type: string
required: true
unit:
description:
- Time unit to convert the duration to.
default: ms
choices:
- millisecond
- milliseconds
- ms
- msec
- msecs
- msecond
- mseconds
- s
- sec
- secs
- second
- seconds
- h
- hour
- hours
- hs
- m
- min
- mins
- minute
- minutes
- d
- ds
- day
- days
- w
- ws
- week
- weeks
- mo
- mos
- month
- months
- y
- ys
- year
- years
type: string
year:
description:
- Number of days per year.
default: 365
type: float
month:
description:
- Number of days per month.
default: 30
type: float
author:
- René Moser (@resmo)
EXAMPLES: |
- name: Convert a duration into seconds
ansible.builtin.debug:
msg: "{{ '1053d 17h 53m -10s 391ms' | community.general.to_time_unit('s') }}"
RETURN:
_value:
description: Number of time units.
type: float