parent
d1712557cb
commit
32901f57d2
|
@ -880,6 +880,11 @@ Minimum text width in columns.
|
||||||
Choose `text/html` alternative if `text/plain` is empty in `multipart/alternative` attachments.
|
Choose `text/html` alternative if `text/plain` is empty in `multipart/alternative` attachments.
|
||||||
.\" default value
|
.\" default value
|
||||||
.Pq Em true
|
.Pq Em true
|
||||||
|
.It Ic show_date_in_my_timezone Ar boolean
|
||||||
|
.Pq Em optional
|
||||||
|
Show Date: in local timezone
|
||||||
|
.\" default value
|
||||||
|
.Pq Em true
|
||||||
.El
|
.El
|
||||||
.Sh LISTING
|
.Sh LISTING
|
||||||
.Bl -tag -width 36n
|
.Bl -tag -width 36n
|
||||||
|
|
|
@ -1111,8 +1111,52 @@ impl Component for MailView {
|
||||||
})+
|
})+
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
let find_offset = |s: &str| -> (bool, (i64, i64)) {
|
||||||
|
let mut diff = (true, (0, 0));
|
||||||
|
if let Some(pos) = s.as_bytes().iter().position(|b| *b == b'+' || *b == b'-') {
|
||||||
|
let offset = &s[pos..];
|
||||||
|
diff.0 = offset.starts_with('+');
|
||||||
|
if let (Ok(hr_offset), Ok(min_offset)) =
|
||||||
|
(offset[1..3].parse::<i64>(), offset[3..5].parse::<i64>())
|
||||||
|
{
|
||||||
|
diff.1 .0 = hr_offset;
|
||||||
|
diff.1 .1 = min_offset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
diff
|
||||||
|
};
|
||||||
|
let orig_date = envelope.date_as_str();
|
||||||
|
let date_str: std::borrow::Cow<str> = if mailbox_settings!(
|
||||||
|
context[self.coordinates.0][&self.coordinates.1]
|
||||||
|
.pager
|
||||||
|
.show_date_in_my_timezone
|
||||||
|
)
|
||||||
|
.is_true()
|
||||||
|
{
|
||||||
|
let local_date = melib::datetime::timestamp_to_string(
|
||||||
|
envelope.timestamp,
|
||||||
|
Some(melib::datetime::RFC822_DATE),
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
let orig_offset = find_offset(orig_date);
|
||||||
|
let local_offset = find_offset(&local_date);
|
||||||
|
if orig_offset == local_offset {
|
||||||
|
orig_date.into()
|
||||||
|
} else {
|
||||||
|
format!(
|
||||||
|
"{} [actual timezone: {}{:02}{:02}]",
|
||||||
|
local_date,
|
||||||
|
if orig_offset.0 { '+' } else { '-' },
|
||||||
|
orig_offset.1 .0,
|
||||||
|
orig_offset.1 .1
|
||||||
|
)
|
||||||
|
.into()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
orig_date.into()
|
||||||
|
};
|
||||||
print_header!(
|
print_header!(
|
||||||
("Date:", envelope.date_as_str()),
|
("Date:", date_str),
|
||||||
("From:", envelope.field_from_to_string()),
|
("From:", envelope.field_from_to_string()),
|
||||||
("To:", envelope.field_to_to_string()),
|
("To:", envelope.field_to_to_string()),
|
||||||
);
|
);
|
||||||
|
|
|
@ -76,6 +76,11 @@ pub struct PagerSettingsOverride {
|
||||||
#[serde(alias = "auto-choose-multipart-alternative")]
|
#[serde(alias = "auto-choose-multipart-alternative")]
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub auto_choose_multipart_alternative: Option<ToggleFlag>,
|
pub auto_choose_multipart_alternative: Option<ToggleFlag>,
|
||||||
|
#[doc = " Show Date: in my timezone"]
|
||||||
|
#[doc = " Default: true"]
|
||||||
|
#[serde(alias = "show-date-in-my-timezone")]
|
||||||
|
#[serde(default)]
|
||||||
|
pub show_date_in_my_timezone: Option<ToggleFlag>,
|
||||||
}
|
}
|
||||||
impl Default for PagerSettingsOverride {
|
impl Default for PagerSettingsOverride {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
|
@ -90,6 +95,7 @@ impl Default for PagerSettingsOverride {
|
||||||
split_long_lines: None,
|
split_long_lines: None,
|
||||||
minimum_width: None,
|
minimum_width: None,
|
||||||
auto_choose_multipart_alternative: None,
|
auto_choose_multipart_alternative: None,
|
||||||
|
show_date_in_my_timezone: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,6 +87,10 @@ pub struct PagerSettings {
|
||||||
alias = "auto-choose-multipart-alternative"
|
alias = "auto-choose-multipart-alternative"
|
||||||
)]
|
)]
|
||||||
pub auto_choose_multipart_alternative: ToggleFlag,
|
pub auto_choose_multipart_alternative: ToggleFlag,
|
||||||
|
/// Show Date: in my timezone
|
||||||
|
/// Default: true
|
||||||
|
#[serde(default = "internal_value_true", alias = "show-date-in-my-timezone")]
|
||||||
|
pub show_date_in_my_timezone: ToggleFlag,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for PagerSettings {
|
impl Default for PagerSettings {
|
||||||
|
@ -102,6 +106,7 @@ impl Default for PagerSettings {
|
||||||
split_long_lines: true,
|
split_long_lines: true,
|
||||||
minimum_width: 80,
|
minimum_width: 80,
|
||||||
auto_choose_multipart_alternative: ToggleFlag::InternalVal(true),
|
auto_choose_multipart_alternative: ToggleFlag::InternalVal(true),
|
||||||
|
show_date_in_my_timezone: ToggleFlag::InternalVal(true),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue