From a01272ab6ed6fde235d6bdc0e63f39a0c1c5eea1 Mon Sep 17 00:00:00 2001 From: Michele Cereda Date: Sat, 8 Feb 2025 14:53:07 +0100 Subject: [PATCH] fix(ansible): better marking of times as formatted --- .vscode/settings.json | 3 +++ snippets/ansible/tasks.yml | 11 ++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 73eb419..0a96b29 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,9 @@ { "editor.formatOnPaste": true, "editor.formatOnSaveMode": "modificationsIfAvailable", + "editor.rulers": [ + 120 + ], "json.schemas": [ { "fileMatch": [ diff --git a/snippets/ansible/tasks.yml b/snippets/ansible/tasks.yml index 647ee8a..0c10bdb 100644 --- a/snippets/ansible/tasks.yml +++ b/snippets/ansible/tasks.yml @@ -870,14 +870,15 @@ - name: Take difference between dotnet (100ns precision) and iso8601 microsecond timestamps vars: date1: '2022-11-15T03:23:13.6869568Z' - date2: '2021-12-15T16:06:24.400087Z' + date2: '2021-12-15 16:06:24.400087Z' date1_short: - # Shorten to microseconds - # Works for any timestamp that has higher than microsecond precision by cutting off anything more precise than that - '{{ date1 | regex_replace("([^.]+)(\.\d{6})(\d*)(.+)", "\1\2\4") }}' + # Cap to microseconds for any timestamp with higher precision + '{{ date1 | regex_replace("([^.]+)(\.\d{6})\d*(.+)", "\1\2\3") }}' iso8601format: '%Y-%m-%dT%H:%M:%S.%fZ' + rfc3339format: '%Y-%m-%d %H:%M:%S.%fZ' ansible.builtin.set_fact: - date_diff_isoed: '{{ (date1_short|to_datetime(iso8601format) - date2|to_datetime(iso8601format)).total_seconds() }}' + date_diff: >- + {{ (date1_short|to_datetime(iso8601format) - date2|to_datetime(rfc3339format)).total_seconds() }} - name: AWS-specific operations tags: