1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use Duration;
/// Unix epoch: Thursday, January 1, 1970 00:00:00 UTC
pub const UNIX_EPOCH: Duration = from_millis;
/// Twitter epoch: Thursday, November 4, 2010 1:42:54.657 UTC
pub const TWITTER_EPOCH: Duration = from_millis;
/// Discord epoch: Thursday, January 1, 2015 00:00:00 UTC
pub const DISCORD_EPOCH: Duration = from_millis;
/// Instagram epoch: Saturday, January 1, 2011 00:00:00 UTC
pub const INSTAGRAM_EPOCH: Duration = from_millis;
/// Mastodon epoch: Thursday, January 1, 1970 00:00:00 UTC
pub const MASTODON_EPOCH: Duration = UNIX_EPOCH;
/// A trait for time sources that return a monotonic or wall-clock timestamp.
///
/// This abstraction allows you to plug in a real system clock, a monotonic
/// timer, or a mocked time source in tests.
///
/// The timestamp type `T` is generic (typically `u64` or `u128`).
///
/// By default, one returned time unit corresponds to one real millisecond.
/// Time sources may override [`GRANULARITY_MILLIS`] to expose coarser clock
/// quanta while still allowing generic code to recover the real duration of a
/// single returned unit.
///
/// # Example
/// ```
/// use ferroid::time::TimeSource;
///
/// struct FixedTime;
/// impl TimeSource<u64> for FixedTime {
/// fn current_millis(&self) -> u64 {
/// 1234
/// }
/// }
///
/// let time = FixedTime;
/// assert_eq!(time.current_millis(), 1234);
/// ```