decrypt_cookies/firefox/items/
mod.rs

1use chrono::{offset::LocalResult, DateTime, TimeZone, Utc};
2
3// pub mod passwd;
4pub mod cookie;
5
6// reference: https://support.moonpoint.com/network/web/browser/firefox/sqlite_cookies.php
7pub(super) trait I64ToMozTime {
8    fn micros_to_moz_utc(self) -> Option<DateTime<Utc>>;
9    fn secs_to_moz_utc(self) -> Option<DateTime<Utc>>;
10}
11
12impl I64ToMozTime for i64 {
13    fn micros_to_moz_utc(self) -> Option<DateTime<Utc>> {
14        match Utc.timestamp_micros(self) {
15            LocalResult::Single(time) => Some(time),
16            LocalResult::Ambiguous(..) | LocalResult::None => None,
17        }
18    }
19    fn secs_to_moz_utc(self) -> Option<DateTime<Utc>> {
20        match Utc.timestamp_opt(self, 0) {
21            LocalResult::Single(time) => Some(time),
22            LocalResult::Ambiguous(..) | LocalResult::None => None,
23        }
24    }
25}