community.general.to_weeks (8.5.0) — filter

Converte a duration string to weeks

| "added in version" 0.2.0 of community.general"

Authors: René Moser (@resmo)

Install collection

Install with ansible-galaxy collection install community.general:==8.5.0


Add to requirements.yml

  collections:
    - name: community.general
      version: 8.5.0

Description

Parse a human readable time duration string and convert to weeks.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Convert a duration into weeks
  ansible.builtin.debug:
    msg: "{{ '1y 7m 5d 30h' | community.general.to_weeks }}"

Inputs

    
year:
    default: 365
    description:
    - Number of days per year.
    type: float

month:
    default: 30
    description:
    - Number of days per month.
    type: float

_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).
    required: true
    type: string

Outputs

_value:
  description: Number of weeks.
  type: float