From 55d26162b329cbb5bcff8ed63e5960bef4a897c8 Mon Sep 17 00:00:00 2001 From: Jonas L Date: Mon, 5 Feb 2024 12:18:53 +0100 Subject: [PATCH] fix!: always return iso-8601 formatted date time (#453) ##### SUMMARY Fixes #91 Always return datetime as iso-8601 formatted strings. ##### ISSUE TYPE - Bugfix Pull Request --- .../fix-always-return-iso-8601-formatted-datetime.yml | 4 ++++ plugins/modules/certificate.py | 4 ++-- plugins/modules/certificate_info.py | 4 ++-- plugins/modules/iso_info.py | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 changelogs/fragments/fix-always-return-iso-8601-formatted-datetime.yml diff --git a/changelogs/fragments/fix-always-return-iso-8601-formatted-datetime.yml b/changelogs/fragments/fix-always-return-iso-8601-formatted-datetime.yml new file mode 100644 index 00000000..8c38dcae --- /dev/null +++ b/changelogs/fragments/fix-always-return-iso-8601-formatted-datetime.yml @@ -0,0 +1,4 @@ +breaking_changes: + - certificate_info - The `not_valid_before` and `not_valid_after` values are now returned as ISO-8601 formatted strings. + - certificate - The `not_valid_before` and `not_valid_after` values are now returned as ISO-8601 formatted strings. + - iso_info - The `deprecated` value is now returned as ISO-8601 formatted strings. diff --git a/plugins/modules/certificate.py b/plugins/modules/certificate.py index ea39be6c..7507d8ed 100644 --- a/plugins/modules/certificate.py +++ b/plugins/modules/certificate.py @@ -165,8 +165,8 @@ def _prepare_result(self): "type": to_native(self.hcloud_certificate.type), "fingerprint": to_native(self.hcloud_certificate.fingerprint), "certificate": to_native(self.hcloud_certificate.certificate), - "not_valid_before": to_native(self.hcloud_certificate.not_valid_before), - "not_valid_after": to_native(self.hcloud_certificate.not_valid_after), + "not_valid_before": to_native(self.hcloud_certificate.not_valid_before.isoformat()), + "not_valid_after": to_native(self.hcloud_certificate.not_valid_after.isoformat()), "domain_names": [to_native(domain) for domain in self.hcloud_certificate.domain_names], "labels": self.hcloud_certificate.labels, } diff --git a/plugins/modules/certificate_info.py b/plugins/modules/certificate_info.py index e074046f..51997095 100644 --- a/plugins/modules/certificate_info.py +++ b/plugins/modules/certificate_info.py @@ -110,8 +110,8 @@ def _prepare_result(self): "name": to_native(certificate.name), "fingerprint": to_native(certificate.fingerprint), "certificate": to_native(certificate.certificate), - "not_valid_before": to_native(certificate.not_valid_before), - "not_valid_after": to_native(certificate.not_valid_after), + "not_valid_before": to_native(certificate.not_valid_before.isoformat()), + "not_valid_after": to_native(certificate.not_valid_after.isoformat()), "domain_names": [to_native(domain) for domain in certificate.domain_names], "labels": certificate.labels, } diff --git a/plugins/modules/iso_info.py b/plugins/modules/iso_info.py index e623d171..77c08b90 100644 --- a/plugins/modules/iso_info.py +++ b/plugins/modules/iso_info.py @@ -149,7 +149,7 @@ def _prepare_result(self): "type": iso_info.type, "architecture": iso_info.architecture, "deprecated": ( - iso_info.deprecation.unavailable_after if iso_info.deprecation is not None else None + iso_info.deprecation.unavailable_after.isoformat() if iso_info.deprecation is not None else None ), "deprecation": ( {