MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / parse_range

Function parse_range

src/accounting/metrics.rs:80–89  ·  view source on GitHub ↗

Parse a range string into a unix timestamp for "since".

(range: &str)

Source from the content-addressed store, hash-verified

78
79/// Parse a range string into a unix timestamp for "since".
80pub fn parse_range(range: &str) -> u64 {
81 let now = now_epoch();
82 match range {
83 "today" => today_start_epoch(now),
84 "30d" => now.saturating_sub(30 * 86400),
85 "month" => month_start_epoch(now),
86 "all" => 0,
87 _ => now.saturating_sub(7 * 86400),
88 }
89}
90
91fn now_epoch() -> u64 {
92 std::time::SystemTime::now()

Callers 5

handle_gainFunction · 0.85
handle_costFunction · 0.85
print_default_summaryFunction · 0.85
test_parse_rangeFunction · 0.85
range_sinceFunction · 0.85

Calls 3

now_epochFunction · 0.85
today_start_epochFunction · 0.85
month_start_epochFunction · 0.85

Tested by 1

test_parse_rangeFunction · 0.68