fix time format
This commit is contained in:
parent
ed1d701d94
commit
a5bca9058a
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -351,7 +351,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "mqttClock"
|
||||
version = "1.2.1"
|
||||
version = "1.3.0"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"crossbeam",
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "mqttClock"
|
||||
version = "1.2.1"
|
||||
version = "1.3.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
|
||||
@ -57,7 +57,9 @@ impl Clock {
|
||||
let minute = self.last_minute;
|
||||
let hour = self.last_hour;
|
||||
if let (Some(second), Some(minute), Some(hour)) = (second, minute, hour) {
|
||||
let payload = format!("{{\"second\":{second},\"minute\":{minute},\"hour\":{hour},\"time\":\"{hour}:{minute}:{second}\"}}");
|
||||
let payload =
|
||||
format!("{{\"second\":{},\"minute\":{},\"hour\":{},\"time\":\"{}:{:02}:{:02}\"}}",
|
||||
second, minute, hour, hour, minute, second);
|
||||
|
||||
let message = MqttMessage {
|
||||
topic: String::from("clock/time/time"),
|
||||
@ -66,7 +68,8 @@ impl Clock {
|
||||
qos: QoS::AtMostOnce,
|
||||
};
|
||||
match self.tx.send(message) {
|
||||
Err(n) => println!("ERROR: faild to send publish ({:?})", n),
|
||||
Err(n) =>
|
||||
println!("ERROR: faild to send publish ({:?})", n),
|
||||
Ok(_) => {}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user