Format times

This commit is contained in:
Sakuhl 2018-03-13 14:05:57 +01:00
parent 12dc48196d
commit 19bd9f7328
2 changed files with 22 additions and 1 deletions

View File

@ -4,6 +4,8 @@ use serenity::model::*;
use failure::Error; use failure::Error;
use chrono::{Datelike, NaiveDateTime};
pub fn wc_player(command: &str, msg: &Message) -> Result<(), Error> { pub fn wc_player(command: &str, msg: &Message) -> Result<(), Error> {
if command.len() <= 7 { if command.len() <= 7 {
bail!("no player specified"); bail!("no player specified");
@ -28,7 +30,24 @@ pub fn wc_player(command: &str, msg: &Message) -> Result<(), Error> {
**Total level**: {}{}", **Total level**: {}{}",
player.username, player.username,
player.guild.name, player.guild.name,
if player.guild.name != "None" { wynncraft::guild(&player.guild.name)?.unwrap().members.iter().filter(|x| x.name == player.username).next().unwrap().joined.clone() } else { "never".to_owned() }, if player.guild.name != "None" {
let date = wynncraft::guild(&player.guild.name)?.unwrap().members.iter().filter(|x| x.name == player.username).next().unwrap().joined.clone();
date[0..date.len()-2].parse::<NaiveDateTime>().map(|x| format!("{} {}, {}", match x.month() {
1 => "January",
2 => "February",
3 => "March",
4 => "April",
5 => "Mai",
6 => "Juni",
7 => "Juli",
8 => "August",
9 => "September",
10 => "October",
11 => "November",
12 => "December",
_ => "<insert Month here>"
}, x.day(), x.year())).unwrap_or(date)
} else { "never".to_owned() },
player.playtime / 60, player.playtime / 60,
player.global.mobs_killed, player.global.pvp_kills, player.global.mobs_killed, player.global.pvp_kills,
player.global.chests_found, player.global.chests_found,

View File

@ -32,6 +32,8 @@ extern crate lazy_static;
extern crate strsim; extern crate strsim;
extern crate chrono;
use std::collections::HashMap; use std::collections::HashMap;
use std::env; use std::env;
use std::panic; use std::panic;