commit 76eda7f73f1c29a0828755676d55ff27a1561658
parent 84bd772636647be68110269f1b09725e82037380
Author: Shimmy Xu <shimmy.xu@shimmy1996.com>
Date: Fri, 4 Oct 2019 17:12:08 -0400
Make absolute time the default in Display
Diffstat:
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/entry.rs b/src/entry.rs
@@ -78,11 +78,11 @@ impl fmt::Display for Entry {
/// Alternate format uses absolute time.
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
let timestamp = if formatter.alternate() {
+ Self::format_duration(Local::now() - self.timestamp.with_timezone(&Local))
+ } else {
self.timestamp
.with_timezone(&Local)
.to_rfc3339_opts(SecondsFormat::Secs, true)
- } else {
- Self::format_duration(Local::now() - self.timestamp.with_timezone(&Local))
};
write!(
@@ -175,12 +175,12 @@ mod tests {
};
assert_eq!(
- format!("{}", entry),
+ format!("{:#}", entry),
format!("@anonymous 1 week ago\nHello world!",)
);
assert_eq!(
- format!("{:#}", entry),
+ format!("{}", entry),
format!(
"@anonymous {}\nHello world!",
timestamp
diff --git a/src/timeline.rs b/src/timeline.rs
@@ -24,9 +24,9 @@ pub fn timeline(config: &Config, _subcommand: &ArgMatches) {
for _ in 0..config.limit_timeline {
if let Some(tweet) = all_tweets.pop() {
if config.use_abs_time {
- println!("\n{:#}", tweet);
- } else {
println!("\n{}", tweet);
+ } else {
+ println!("\n{:#}", tweet);
}
}
}