Skip to content

Commit c84e59e

Browse files
authored
Revert "add current time indicator to graph (#44)"
This reverts commit c72d408.
1 parent c72d408 commit c84e59e

File tree

4 files changed

+18
-52
lines changed

4 files changed

+18
-52
lines changed

src/modules/display/border.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ impl Separator {
106106
Border::R.fmt(border_variant)
107107
),
108108
Self::Dashed => format!("├{:┈>width$}┤", ""),
109-
Self::Single => format!("├{:─>width$}", ""),
109+
Self::Single => format!("{}{:─>width$}{}", '├', "", '┤'),
110110
Self::Solid => format!("┠{:─>width$}┨", ""),
111111
Self::Double => format!("╟{:─>width$}╢", ""),
112112
}

src/modules/display/current.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ impl Current {
256256
};
257257

258258
let hourly_forecast = match add_hourly {
259-
true => Some(Graph::prepare(weather, current_hour, night, graph_variant, lang).await?),
259+
true => Some(Graph::prepare(weather, night, graph_variant, lang).await?),
260260
_ => None,
261261
};
262262

src/modules/display/forecast.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ impl Forecast {
121121
&match border_variant {
122122
BorderVariant::double => Separator::Double.fmt(width, border_variant),
123123
BorderVariant::solid => Separator::Solid.fmt(width, border_variant),
124-
_ => Separator::Dashed.fmt(width, border_variant),
124+
_ => Separator::Single.fmt(width, border_variant),
125125
}
126126
.color_option(BrightBlack, color_variant)
127127
)

src/modules/display/graph.rs

+15-49
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use anyhow::Result;
2-
use chrono::{Timelike, Utc};
32
use colored::{
43
Color::{Blue, BrightBlack, Yellow},
54
Colorize,
@@ -23,7 +22,6 @@ pub struct Graph {
2322
temperatures: String,
2423
graph: String,
2524
precipitation: String,
26-
time_indicator_col: usize,
2725
}
2826

2927
#[derive(Default, Serialize, Deserialize, PartialEq, Eq, Debug, Clone, Copy)]
@@ -67,8 +65,12 @@ impl Graph {
6765

6866
println!(
6967
"{}",
70-
self.prepare_separator(border_variant, width, '╤')
71-
.color_option(BrightBlack, color_variant),
68+
&match border_variant {
69+
BorderVariant::double => Separator::Double.fmt(width, border_variant),
70+
BorderVariant::solid => Separator::Solid.fmt(width, border_variant),
71+
_ => Separator::Dashed.fmt(width, border_variant),
72+
}
73+
.color_option(BrightBlack, color_variant)
7274
);
7375

7476
println!(
@@ -103,8 +105,12 @@ impl Graph {
103105

104106
println!(
105107
"{}",
106-
self.prepare_separator(border_variant, width, '╧')
107-
.color_option(BrightBlack, color_variant),
108+
match border_variant {
109+
BorderVariant::double => Separator::Double.fmt(width, border_variant),
110+
BorderVariant::solid => Separator::Solid.fmt(width, border_variant),
111+
_ => Separator::Dashed.fmt(width, border_variant),
112+
}
113+
.color_option(BrightBlack, color_variant)
108114
);
109115

110116
let hours = match units.time {
@@ -124,24 +130,12 @@ impl Graph {
124130
);
125131
}
126132

127-
pub async fn prepare(
128-
weather: &Weather,
129-
current_hour: usize,
130-
night: bool,
131-
graph_variant: &GraphVariant,
132-
lang: &str,
133-
) -> Result<Self> {
133+
pub async fn prepare(weather: &Weather, night: bool, graph_variant: &GraphVariant, lang: &str) -> Result<Self> {
134134
let temperatures = Self::prepare_temperature(weather, night, lang).await?;
135135
let precipitation = Self::prepare_precipitation(&weather.hourly.precipitation[..=24])?;
136136
let graph = Self::prepare_graph(&weather.hourly.temperature_2m[..=24], graph_variant)?;
137-
let time_indicator_col = current_hour * 3 + (Timelike::minute(&Utc::now()) / 20) as usize;
138-
139-
Ok(Graph {
140-
temperatures,
141-
graph,
142-
time_indicator_col,
143-
precipitation,
144-
})
137+
138+
Ok(Graph { temperatures, graph, precipitation })
145139
}
146140

147141
async fn prepare_temperature(weather: &Weather, night: bool, lang: &str) -> Result<String> {
@@ -219,32 +213,4 @@ impl Graph {
219213

220214
Ok(graph)
221215
}
222-
223-
fn prepare_separator(&self, border_variant: &BorderVariant, width: usize, time_indicator: char) -> String {
224-
let col_correction = 3;
225-
226-
match border_variant {
227-
BorderVariant::double => format!(
228-
"╟{:─>current_hour$}{:─>width$}╢",
229-
time_indicator,
230-
"",
231-
current_hour = self.time_indicator_col + col_correction,
232-
width = width - self.time_indicator_col - col_correction
233-
),
234-
BorderVariant::solid => format!(
235-
"┠{:─>current_hour$}{:─>width$}┨",
236-
time_indicator,
237-
"",
238-
current_hour = self.time_indicator_col + col_correction,
239-
width = width - self.time_indicator_col - col_correction
240-
),
241-
_ => format!(
242-
"├{:┈>current_hour$}{:┈>width$}┤",
243-
time_indicator,
244-
"",
245-
current_hour = self.time_indicator_col + col_correction,
246-
width = width - self.time_indicator_col - col_correction
247-
),
248-
}
249-
}
250216
}

0 commit comments

Comments
 (0)