|
@@ -122,17 +122,37 @@ impl DefaultFormat {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
impl DefaultFormat {
|
|
impl DefaultFormat {
|
|
|
fn is_recent(&self, date: LocalDateTime) -> bool {
|
|
fn is_recent(&self, date: LocalDateTime) -> bool {
|
|
|
date.year() == self.current_year
|
|
date.year() == self.current_year
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ fn month_to_abbrev(month: datetime::Month) -> &'static str {
|
|
|
|
|
+ match month {
|
|
|
|
|
+ datetime::Month::January => "Jan",
|
|
|
|
|
+ datetime::Month::February => "Feb",
|
|
|
|
|
+ datetime::Month::March => "Mar",
|
|
|
|
|
+ datetime::Month::April => "Apr",
|
|
|
|
|
+ datetime::Month::May => "May",
|
|
|
|
|
+ datetime::Month::June => "Jun",
|
|
|
|
|
+ datetime::Month::July => "Jul",
|
|
|
|
|
+ datetime::Month::August => "August",
|
|
|
|
|
+ datetime::Month::September => "Sep",
|
|
|
|
|
+ datetime::Month::October => "Oct",
|
|
|
|
|
+ datetime::Month::November => "Nov",
|
|
|
|
|
+ datetime::Month::December => "Dec",
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
#[allow(trivial_numeric_casts)]
|
|
#[allow(trivial_numeric_casts)]
|
|
|
fn format_local(&self, time: Duration) -> String {
|
|
fn format_local(&self, time: Duration) -> String {
|
|
|
let date = LocalDateTime::at(time.as_secs() as i64);
|
|
let date = LocalDateTime::at(time.as_secs() as i64);
|
|
|
|
|
|
|
|
if self.is_recent(date) {
|
|
if self.is_recent(date) {
|
|
|
- self.date_and_time.format(&date, &self.locale)
|
|
|
|
|
|
|
+ format!("{:2} {} {:02}:{:02}",
|
|
|
|
|
+ date.day(), DefaultFormat::month_to_abbrev(date.month()),
|
|
|
|
|
+ date.hour(), date.minute())
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
|
self.date_and_year.format(&date, &self.locale)
|
|
self.date_and_year.format(&date, &self.locale)
|
|
@@ -144,7 +164,9 @@ impl DefaultFormat {
|
|
|
let date = zone.to_zoned(LocalDateTime::at(time.as_secs() as i64));
|
|
let date = zone.to_zoned(LocalDateTime::at(time.as_secs() as i64));
|
|
|
|
|
|
|
|
if self.is_recent(date) {
|
|
if self.is_recent(date) {
|
|
|
- self.date_and_time.format(&date, &self.locale)
|
|
|
|
|
|
|
+ format!("{:2} {} {:02}:{:02}",
|
|
|
|
|
+ date.day(), DefaultFormat::month_to_abbrev(date.month()),
|
|
|
|
|
+ date.hour(), date.minute())
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
|
self.date_and_year.format(&date, &self.locale)
|
|
self.date_and_year.format(&date, &self.locale)
|
|
@@ -153,6 +175,7 @@ impl DefaultFormat {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
#[allow(trivial_numeric_casts)]
|
|
#[allow(trivial_numeric_casts)]
|
|
|
fn long_local(time: Duration) -> String {
|
|
fn long_local(time: Duration) -> String {
|
|
|
let date = LocalDateTime::at(time.as_secs() as i64);
|
|
let date = LocalDateTime::at(time.as_secs() as i64);
|