Skip to content

refactor(util): extract parse_time_to_datetime helper - #402

Merged
platinummonkey merged 1 commit into
mainfrom
refactor/timestamp-parsing-helper
Apr 23, 2026
Merged

refactor(util): extract parse_time_to_datetime helper#402
platinummonkey merged 1 commit into
mainfrom
refactor/timestamp-parsing-helper

Conversation

@platinummonkey

Copy link
Copy Markdown
Collaborator

Summary

  • Extracts the repeated chrono::DateTime::from_timestamp_millis(util::parse_time_to_unix_millis(&x)?).unwrap() pattern into util::parse_time_to_datetime.
  • Eliminates ~14 .unwrap() panic paths on user-supplied time input across 6 command modules.

Changes

  • New helper parse_time_to_datetime in src/util.rs with positive and negative tests
  • Call sites updated: security.rs, cicd.rs, usage.rs, cost.rs, audit_logs.rs, rum.rs

Testing

  • cargo fmt --check
  • cargo clippy -- -D warnings
  • cargo test — new util tests + existing suite all pass

🤖 Generated with Claude Code

Replaces the repeated `from_timestamp_millis(...).unwrap()` pattern in
command modules with a single helper in util.rs that returns a proper
anyhow error on out-of-range timestamps. Eliminates a panic path on
user-supplied time input.

- Add util::parse_time_to_datetime with positive and negative tests
- Update security, cicd, usage, cost, audit_logs, rum command modules

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@platinummonkey
platinummonkey merged commit 98148f9 into main Apr 23, 2026
9 checks passed
@platinummonkey
platinummonkey deleted the refactor/timestamp-parsing-helper branch April 23, 2026 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant