From d6dec54a5f18c02207d7f9a9a75df316d0419696 Mon Sep 17 00:00:00 2001 From: Sylvain Hellegouarch Date: Thu, 18 Jan 2024 14:58:02 +0100 Subject: [PATCH] support up to years Signed-off-by: Sylvain Hellegouarch --- CHANGELOG.md | 10 +++++++++- chaosaws/__init__.py | 9 ++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2766272..8aeeb09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,15 @@ ## [Unreleased][] -[Unreleased]: https://github.com/chaostoolkit-incubator/chaostoolkit-aws/compare/0.29.0...HEAD +[Unreleased]: https://github.com/chaostoolkit-incubator/chaostoolkit-aws/compare/0.29.1...HEAD + +## [0.29.1][] - 2024-01-18 + +[0.29.1]: https://github.com/chaostoolkit-incubator/chaostoolkit-aws/compare/0.29.0...0.29.1 + +### Added + +- Offset supported to months and years ## [0.29.0][] - 2023-12-10 diff --git a/chaosaws/__init__.py b/chaosaws/__init__.py index 029d755..95124c5 100644 --- a/chaosaws/__init__.py +++ b/chaosaws/__init__.py @@ -16,7 +16,7 @@ from chaoslib.types import Configuration, DiscoveredActivities, Discovery, Secrets from logzero import logger -__version__ = "0.29.0" +__version__ = "0.29.1" __all__ = ["__version__", "discover", "aws_client", "signed_api_call"] @@ -286,6 +286,13 @@ def time_to_datetime( delta = 60 * 60 elif unit in ("day", "days"): delta = 60 * 60 * 24 + elif unit in ("month", "months"): + delta = 60 * 60 * 24 * 30 + elif unit in ("year", "years"): + delta = 60 * 60 * 24 * 365 + else: + # let's default to the last 5mn + delta = 300 return offset - timedelta(seconds=duration * delta)