aboutsummaryrefslogtreecommitdiff
path: root/src/http
diff options
context:
space:
mode:
authorZeyla Hellyer <[email protected]>2017-06-04 20:32:25 -0700
committerZeyla Hellyer <[email protected]>2017-06-06 10:12:13 -0700
commit990e611a56f37f64fbce74fbc487c7dcc4aa4e28 (patch)
tree399c69583bd256d31668affc227f235386814552 /src/http
parentAdd CurrentUser::face(), User::face() (diff)
downloadserenity-990e611a56f37f64fbce74fbc487c7dcc4aa4e28.tar.xz
serenity-990e611a56f37f64fbce74fbc487c7dcc4aa4e28.zip
Use chrono for struct timestamp fields
Chrono is easier to use than timestamped strings, so they should be automatically deserialized and available for the user, instead of having the user deserialize the strings themselves. These fields have been changed to use a type of `DateTime<FixedOffset>`: - `ChannelPinsUpdateEvent.last_pin_timestamp` - `Group.last_pin_timestamp` - `Guild.joined_at` - `GuildChannel.last_pin_timestamp` - `Invite.created_at` - `Member.joined_at` - `Message.edited_timestamp - `Message.timestamp` - `MessageUpdateEvent.edited_timestamp` - `MessageUpdateEvent.timestamp` - `PrivateChannel.last_pin_timestamp` `Member.joined_at` is now also an `Option`. Previously, if a Guild Member Update was received for a member not in the cache, a new Member would be instantiated with a default String value. This is incorrect behaviour, and has now been replaced with being set to `None` in that case. Id methods' `created_at()` method now return a `chrono::NaiveDateTime` instead of a `time::Timespec`, and `User::created_at` has been updated to reflect that. Additionally, drop `time` as a direct dependency and use chrono for internals.
Diffstat (limited to 'src/http')
-rw-r--r--src/http/ratelimiting.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/http/ratelimiting.rs b/src/http/ratelimiting.rs
index 95318ae..d290dd0 100644
--- a/src/http/ratelimiting.rs
+++ b/src/http/ratelimiting.rs
@@ -40,6 +40,7 @@
//! [Taken from]: https://discordapp.com/developers/docs/topics/rate-limits#rate-limits
#![allow(zero_ptr)]
+use chrono::UTC;
use hyper::client::{RequestBuilder, Response};
use hyper::header::Headers;
use hyper::status::StatusCode;
@@ -48,7 +49,6 @@ use std::sync::{Arc, Mutex};
use std::time::Duration;
use std::{i64, str, thread};
use super::{HttpError, LightMethod};
-use time;
use ::internal::prelude::*;
lazy_static! {
@@ -441,7 +441,7 @@ impl RateLimit {
return;
}
- let current_time = time::get_time().sec;
+ let current_time = UTC::now().timestamp();
// The reset was in the past, so we're probably good.
if current_time > self.reset {