Parse a range string into a unix timestamp for "since".
(range: &str)
| 78 | |
| 79 | /// Parse a range string into a unix timestamp for "since". |
| 80 | pub 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 | |
| 91 | fn now_epoch() -> u64 { |
| 92 | std::time::SystemTime::now() |