clock/date: Feb 29 bug in nonsensical code
This commit is contained in:
@@ -2,7 +2,7 @@ use crate::color::Color;
|
|||||||
use crate::draw::{Font, ROBOTO_REGULAR};
|
use crate::draw::{Font, ROBOTO_REGULAR};
|
||||||
use crate::widget::{DrawContext, DrawReport, KeyState, ModifiersState, WaitContext, Widget};
|
use crate::widget::{DrawContext, DrawReport, KeyState, ModifiersState, WaitContext, Widget};
|
||||||
|
|
||||||
use chrono::{DateTime, Datelike, Duration, Local, Timelike};
|
use chrono::{DateTime, Duration, Local, Timelike};
|
||||||
|
|
||||||
pub struct Clock {
|
pub struct Clock {
|
||||||
cur_time: DateTime<Local>,
|
cur_time: DateTime<Local>,
|
||||||
@@ -15,10 +15,8 @@ impl Clock {
|
|||||||
let mut clock_cache = Font::new(&ROBOTO_REGULAR, size);
|
let mut clock_cache = Font::new(&ROBOTO_REGULAR, size);
|
||||||
clock_cache.add_str_to_cache("0123456789:");
|
clock_cache.add_str_to_cache("0123456789:");
|
||||||
|
|
||||||
let time = Local::now();
|
|
||||||
|
|
||||||
Box::new(Clock {
|
Box::new(Clock {
|
||||||
cur_time: time.with_year(time.year().saturating_sub(1)).unwrap(),
|
cur_time: Local::now(),
|
||||||
clock_cache: clock_cache,
|
clock_cache: clock_cache,
|
||||||
size: size,
|
size: size,
|
||||||
})
|
})
|
||||||
|
|||||||
+1
-3
@@ -16,10 +16,8 @@ impl Date {
|
|||||||
date_cache
|
date_cache
|
||||||
.add_str_to_cache("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789,/ ");
|
.add_str_to_cache("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789,/ ");
|
||||||
|
|
||||||
let time = Local::now();
|
|
||||||
|
|
||||||
Box::new(Date {
|
Box::new(Date {
|
||||||
cur_time: time.with_year(time.year().saturating_sub(1)).unwrap(),
|
cur_time: Local::now(),
|
||||||
date_cache: date_cache,
|
date_cache: date_cache,
|
||||||
size: size,
|
size: size,
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user