aboutsummaryrefslogtreecommitdiff
path: root/src/model/channel
diff options
context:
space:
mode:
Diffstat (limited to 'src/model/channel')
-rw-r--r--src/model/channel/group.rs3
-rw-r--r--src/model/channel/guild_channel.rs3
-rw-r--r--src/model/channel/message.rs25
-rw-r--r--src/model/channel/private_channel.rs3
4 files changed, 17 insertions, 17 deletions
diff --git a/src/model/channel/group.rs b/src/model/channel/group.rs
index 25c4690..63efb90 100644
--- a/src/model/channel/group.rs
+++ b/src/model/channel/group.rs
@@ -1,3 +1,4 @@
+use chrono::{DateTime, FixedOffset};
use ::model::*;
#[cfg(feature="model")]
@@ -26,7 +27,7 @@ pub struct Group {
/// The Id of the last message sent.
pub last_message_id: Option<MessageId>,
/// Timestamp of the latest pinned message.
- pub last_pin_timestamp: Option<String>,
+ pub last_pin_timestamp: Option<DateTime<FixedOffset>>,
/// The name of the group channel.
pub name: Option<String>,
/// The Id of the group owner.
diff --git a/src/model/channel/guild_channel.rs b/src/model/channel/guild_channel.rs
index 8b55d04..5ce7031 100644
--- a/src/model/channel/guild_channel.rs
+++ b/src/model/channel/guild_channel.rs
@@ -1,3 +1,4 @@
+use chrono::{DateTime, FixedOffset};
use ::model::*;
#[cfg(feature="model")]
@@ -46,7 +47,7 @@ pub struct GuildChannel {
/// The timestamp of the time a pin was most recently made.
///
/// **Note**: This is only available for text channels.
- pub last_pin_timestamp: Option<String>,
+ pub last_pin_timestamp: Option<DateTime<FixedOffset>>,
/// The name of the channel.
pub name: String,
/// Permission overwrites for [`Member`]s and for [`Role`]s.
diff --git a/src/model/channel/message.rs b/src/model/channel/message.rs
index 8b9f0af..612113d 100644
--- a/src/model/channel/message.rs
+++ b/src/model/channel/message.rs
@@ -1,3 +1,4 @@
+use chrono::{DateTime, FixedOffset};
use ::model::*;
#[cfg(feature="cache")]
@@ -5,8 +6,6 @@ use std::fmt::Write;
#[cfg(feature="model")]
use std::mem;
#[cfg(feature="model")]
-use time;
-#[cfg(feature="model")]
use ::builder::{CreateEmbed, CreateMessage};
#[cfg(feature="model")]
use ::constants;
@@ -33,7 +32,7 @@ pub struct Message {
/// The content of the message.
pub content: String,
/// The timestamp of the last time the message was updated, if it was.
- pub edited_timestamp: Option<String>,
+ pub edited_timestamp: Option<DateTime<FixedOffset>>,
/// Array of embeds sent with the message.
pub embeds: Vec<Embed>,
/// Indicator of the type of message this is, i.e. whether it is a regular
@@ -56,7 +55,7 @@ pub struct Message {
#[serde(default)]
pub reactions: Vec<MessageReaction>,
/// Initial message creation timestamp, calculated from its Id.
- pub timestamp: String,
+ pub timestamp: DateTime<FixedOffset>,
/// Indicator of whether the command is to be played back via
/// text-to-speech.
///
@@ -240,16 +239,14 @@ impl Message {
self.content = format!("{} pinned a message to this channel. See all the pins.", self.author);
},
MessageType::MemberJoin => {
- if let Ok(tm) = time::strptime(&self.timestamp, "%Y-%m-%dT%H:%M:%S") {
- let sec = tm.to_timespec().sec as usize;
- let chosen = constants::JOIN_MESSAGES[sec % constants::JOIN_MESSAGES.len()];
-
- self.content = if chosen.contains("$user") {
- chosen.replace("$user", &self.author.mention())
- } else {
- chosen.to_owned()
- };
- }
+ let sec = self.timestamp.timestamp() as usize;
+ let chosen = constants::JOIN_MESSAGES[sec % constants::JOIN_MESSAGES.len()];
+
+ self.content = if chosen.contains("$user") {
+ chosen.replace("$user", &self.author.mention())
+ } else {
+ chosen.to_owned()
+ };
},
_ => {},
}
diff --git a/src/model/channel/private_channel.rs b/src/model/channel/private_channel.rs
index 7a0ed54..797ba94 100644
--- a/src/model/channel/private_channel.rs
+++ b/src/model/channel/private_channel.rs
@@ -1,3 +1,4 @@
+use chrono::{DateTime, FixedOffset};
use std::fmt::{Display, Formatter, Result as FmtResult};
use super::deserialize_single_recipient;
use ::model::*;
@@ -21,7 +22,7 @@ pub struct PrivateChannel {
/// Timestamp of the last time a [`Message`] was pinned.
///
/// [`Message`]: struct.Message.html
- pub last_pin_timestamp: Option<String>,
+ pub last_pin_timestamp: Option<DateTime<FixedOffset>>,
/// Indicator of the type of channel this is.
///
/// This should always be [`ChannelType::Private`].