Merge branch 'imag-log-show-multiple-sort-by-date' into master
This commit is contained in:
commit
a9bde370a3
2 changed files with 9 additions and 1 deletions
|
@ -173,7 +173,7 @@ fn show(rt: &Runtime) {
|
||||||
})
|
})
|
||||||
.filter(|e| e.is_log().map_err_trace_exit_unwrap())
|
.filter(|e| e.is_log().map_err_trace_exit_unwrap())
|
||||||
.map(|entry| (entry.diary_id().map_err_trace_exit_unwrap(), entry))
|
.map(|entry| (entry.diary_id().map_err_trace_exit_unwrap(), entry))
|
||||||
.sorted_by_key(|tpl| tpl.0.clone())
|
.sorted_by_key(|tpl| tpl.0.get_date_representation())
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|tpl| { debug!("Found entry: {:?}", tpl.1); tpl })
|
.map(|tpl| { debug!("Found entry: {:?}", tpl.1); tpl })
|
||||||
.map(|(id, entry)| {
|
.map(|(id, entry)| {
|
||||||
|
|
|
@ -132,6 +132,14 @@ impl DiaryId {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get the date how it is stored in the DiaryId object
|
||||||
|
///
|
||||||
|
/// This can be useful for sorting a list of diary entries by date, but not using
|
||||||
|
/// Into<NaiveDateTime>
|
||||||
|
pub fn get_date_representation(&self) -> (i32, u32, u32, u32, u32, u32) {
|
||||||
|
(self.year, self.month, self.day, self.hour, self.minute, self.second)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn now(name: String) -> DiaryId {
|
pub fn now(name: String) -> DiaryId {
|
||||||
use chrono::offset::Local;
|
use chrono::offset::Local;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue