From ee7a908ebcd52040c6087682ccbd36021b75bae7 Mon Sep 17 00:00:00 2001 From: Stefan Sterz Date: Thu, 9 Nov 2023 16:33:59 +0100 Subject: [PATCH] subscription: expose the `next_due_date` as an `i64` internally `SubscriptionInfo` already uses the `parse_next_due` helper to parse the next due date to an epoch. this exposes a function that allows us to use the epoch outside of this crate too. for example, a user of pom may have multiple subscription for the same system. in that case we want to apply the one with the due date that is furthest in the future. Signed-off-by: Stefan Sterz --- proxmox-subscription/src/subscription_info.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/proxmox-subscription/src/subscription_info.rs b/proxmox-subscription/src/subscription_info.rs index 42d7987f..ae40dbff 100644 --- a/proxmox-subscription/src/subscription_info.rs +++ b/proxmox-subscription/src/subscription_info.rs @@ -286,6 +286,13 @@ impl SubscriptionInfo { .ok_or_else(|| format_err!("no product key set")) .map(|key| key[..3].parse::())? } + + pub fn get_next_due_date(&self) -> Result { + self.nextduedate + .as_ref() + .ok_or_else(|| format_err!("no next due date set")) + .map(|e| parse_next_due(e))? + } } /// Shortcut for md5 sums.