Skip to content

Commit 4954965

Browse files
committed
fix(enterprise): improve license date parsing for ISO8601 format
- Add support for RFC3339/ISO8601 datetime format (e.g., 2025-10-15T00:18:29Z) - Maintain backward compatibility with date-only format (e.g., 2025-10-15) - Fixes days_remaining calculation to correctly show 30 days instead of -1 - All license commands now working correctly with actual Enterprise API responses
1 parent d0e43e5 commit 4954965

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

crates/redisctl/src/commands/enterprise/license.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -330,12 +330,20 @@ async fn handle_license_usage(
330330

331331
// Helper functions
332332
pub fn calculate_days_remaining(expiration_date: Option<&str>) -> i64 {
333-
if let Some(date_str) = expiration_date
334-
&& let Ok(exp_date) = chrono::NaiveDate::parse_from_str(date_str, "%Y-%m-%d")
335-
{
336-
let today = chrono::Local::now().naive_local().date();
337-
let duration = exp_date.signed_duration_since(today);
338-
return duration.num_days();
333+
if let Some(date_str) = expiration_date {
334+
// Try parsing as ISO8601 datetime first (e.g., "2025-10-15T00:18:29Z")
335+
if let Ok(datetime) = chrono::DateTime::parse_from_rfc3339(date_str) {
336+
let today = chrono::Local::now().naive_local().date();
337+
let exp_date = datetime.naive_local().date();
338+
let duration = exp_date.signed_duration_since(today);
339+
return duration.num_days();
340+
}
341+
// Fall back to parsing as date only (e.g., "2025-10-15")
342+
if let Ok(exp_date) = chrono::NaiveDate::parse_from_str(date_str, "%Y-%m-%d") {
343+
let today = chrono::Local::now().naive_local().date();
344+
let duration = exp_date.signed_duration_since(today);
345+
return duration.num_days();
346+
}
339347
}
340348
-1
341349
}

0 commit comments

Comments
 (0)