mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Adds the ability to change time with /time with HH:MM format. e.g. 12:43
This commit is contained in:
parent
c077c54690
commit
dbe9c5d696
@ -18,3 +18,4 @@ ron = "0.5.1"
|
||||
serde = "1.0"
|
||||
serde_derive = "1.0"
|
||||
rand = "0.5.6"
|
||||
chrono = "0.4.7"
|
||||
|
@ -9,6 +9,7 @@ use common::{
|
||||
npc::{get_npc_name, NpcKind},
|
||||
state::TimeOfDay,
|
||||
};
|
||||
use chrono::{NaiveTime, Timelike};
|
||||
use rand::Rng;
|
||||
use specs::{Builder, Entity as EcsEntity, Join};
|
||||
use vek::*;
|
||||
@ -217,12 +218,14 @@ fn handle_time(server: &mut Server, entity: EcsEntity, args: String, action: &Ch
|
||||
Some("dusk") => 17.0 * 3600.0,
|
||||
Some(n) => match n.parse() {
|
||||
Ok(n) => n,
|
||||
Err(_) => {
|
||||
server.clients.notify(
|
||||
entity,
|
||||
ServerMsg::private(format!("'{}' is not a time!", n)),
|
||||
);
|
||||
return;
|
||||
Err(_) => match NaiveTime::parse_from_str(n, "%H:%M") {
|
||||
Ok(time) => time.num_seconds_from_midnight() as f64,
|
||||
Err(_) => {
|
||||
server
|
||||
.clients
|
||||
.notify(entity, ServerMsg::private(format!("'{}' is not a valid time.", n)));
|
||||
return;
|
||||
}
|
||||
}
|
||||
},
|
||||
None => {
|
||||
|
Loading…
Reference in New Issue
Block a user