diff options
| author | Austin Hellyer <[email protected]> | 2016-11-21 13:47:25 -0800 |
|---|---|---|
| committer | Austin Hellyer <[email protected]> | 2016-11-21 13:47:25 -0800 |
| commit | d89739a0084b368f29673a0487af74409d68965c (patch) | |
| tree | d6462ed17555602ff499678959bbe2ede2a87be6 /src/model/mod.rs | |
| parent | Make Context::channel_id public (diff) | |
| download | serenity-d89739a0084b368f29673a0487af74409d68965c.tar.xz serenity-d89739a0084b368f29673a0487af74409d68965c.zip | |
Add created_at method to Ids and User
Returns a Timespec of when the Id (or User) was created.
Diffstat (limited to 'src/model/mod.rs')
| -rw-r--r-- | src/model/mod.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/model/mod.rs b/src/model/mod.rs index 0b93823..20dfabb 100644 --- a/src/model/mod.rs +++ b/src/model/mod.rs @@ -33,6 +33,7 @@ pub use self::webhook::*; use self::utils::*; use std::collections::HashMap; use std::fmt; +use time::Timespec; use ::internal::prelude::*; use ::utils::{Colour, decode_array}; @@ -63,6 +64,12 @@ macro_rules! id { fn decode(value: Value) -> Result<Self> { decode_id(value).map($name) } + + /// Retrieves the time that the Id was created at. + pub fn created_at(&self) -> Timespec { + let offset = (self.0 >> 22) / 1000; + Timespec::new(1420070400 + offset as i64, 0) + } } impl fmt::Display for $name { |