summaryrefslogtreecommitdiff
path: root/rust/src/message.rs
diff options
context:
space:
mode:
authorYves Fischer <yvesf-git@xapek.org>2016-12-15 20:50:23 +0100
committerYves Fischer <yvesf-git@xapek.org>2016-12-17 15:10:46 +0100
commit6ec284ba70e736bc24523b279303cee46b06071a (patch)
tree5ab18399d663b722bdc312430f37c39a49d9a810 /rust/src/message.rs
parent285f0b800d9428c19530a17e25be069e38e2542d (diff)
downloadauth-xmppmessage-6ec284ba70e736bc24523b279303cee46b06071a.tar.gz
auth-xmppmessage-6ec284ba70e736bc24523b279303cee46b06071a.zip
Replace switch -u with header X-Allowed-Jid
Diffstat (limited to 'rust/src/message.rs')
-rw-r--r--rust/src/message.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/rust/src/message.rs b/rust/src/message.rs
new file mode 100644
index 0000000..0af1a13
--- /dev/null
+++ b/rust/src/message.rs
@@ -0,0 +1,22 @@
+///! Formats the message to be sent to the user
+use time::{at_utc, Timespec, strftime};
+
+
+pub fn format_message(token: String, valid_from: i64, valid_until: i64) -> String {
+ return format!("Token: {}. Valid from {} until {}",
+ token,
+ strftime("%F %X", &at_utc(Timespec::new(valid_from, 0))).unwrap(),
+ strftime("%F %X", &at_utc(Timespec::new(valid_until, 0))).unwrap());
+}
+
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn test1() {
+ assert_eq!(format_message("7A-74-F4".to_string(), 0, 1481831953),
+ "Token: 7A-74-F4. Valid from 1970-01-01 00:00:00 until 2016-12-15 19:59:13");
+ }
+} \ No newline at end of file