diff options
author | iximeow <me@iximeow.net> | 2017-12-12 00:36:15 -0800 |
---|---|---|
committer | iximeow <me@iximeow.net> | 2017-12-12 00:36:15 -0800 |
commit | ec71ba2bf8a502ccfc215c1f2ab3785a40c1474f (patch) | |
tree | 03d64742a3dab7d18792814f62650d9758b1610e /src | |
parent | 26d47bb25688b9a03b6425631f1c65f3c4c8dc09 (diff) |
fix incorrect preferred id selection
references to UTC date rather than adjusted-to-local-TZ date meant that
calendar mismatch happens when UTC calendar day moves forward, rather
than local TZ calendar day
in reality, this means if you're PST, and it's 4:01pm, all tweet ids
turn into Bare :1235567 form, rather than changing over at midnight.
Additionally, found a similar issue with id presentation for reply ids
Diffstat (limited to 'src')
-rw-r--r-- | src/tw/mod.rs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/tw/mod.rs b/src/tw/mod.rs index 0e5ec37..a8db62f 100644 --- a/src/tw/mod.rs +++ b/src/tw/mod.rs @@ -386,26 +386,26 @@ impl IdConversions { id @ &TweetId::Bare(_) => { tweeter.retrieve_tweet(id).and_then(|tweet| { let now = Local::now(); - let tweet_date = tweet.recieved_at.with_timezone(&now.timezone()); + let tweet_date = tweet.recieved_at.with_timezone(&Local); if now.year() == tweet_date.year() && now.month() == tweet_date.month() && now.day() == tweet_date.day() { - let date_string = format!("{:04}{:02}{:02}", tweet.recieved_at.year(), tweet.recieved_at.month(), tweet.recieved_at.day()); + let date_string = format!("{:04}{:02}{:02}", tweet_date.year(), tweet_date.month(), tweet_date.day()); let today_id = self.tweets_by_date_and_tweet_id.get(&date_string).and_then(|m| m.get(&tweet.internal_id)); today_id.map(|x| TweetId::Today(*x)) } else { - None + Some(TweetId::Bare(tweet.internal_id)) } }).unwrap_or(id.to_owned()) }, id @ &TweetId::Twitter(_) => { tweeter.retrieve_tweet(id).and_then(|tweet| { let now = Local::now(); - let tweet_date = tweet.recieved_at.with_timezone(&now.timezone()); + let tweet_date = tweet.recieved_at.with_timezone(&Local); if now.year() == tweet_date.year() && now.month() == tweet_date.month() && now.day() == tweet_date.day() { - let date_string = format!("{:04}{:02}{:02}", tweet.recieved_at.year(), tweet.recieved_at.month(), tweet.recieved_at.day()); + let date_string = format!("{:04}{:02}{:02}", tweet_date.year(), tweet_date.month(), tweet_date.day()); let today_id = self.tweets_by_date_and_tweet_id.get(&date_string).and_then(|m| m.get(&tweet.internal_id)); today_id.map(|x| TweetId::Today(*x)) } else { - None + Some(TweetId::Bare(tweet.internal_id)) } }).unwrap_or(id.to_owned()) } @@ -747,7 +747,7 @@ impl TwitterCache { if tw.internal_id == 0 { tw.internal_id = (self.tweets.len() as u64) + 1; self.id_conversions.id_to_tweet_id.insert(tw.internal_id, tw.id.to_owned()); - let local_recv_time = tw.recieved_at.with_timezone(&Local::now().timezone()); + let local_recv_time = tw.recieved_at.with_timezone(&Local); let tweet_date = format!("{:04}{:02}{:02}", local_recv_time.year(), local_recv_time.month(), local_recv_time.day()); if !self.id_conversions.tweets_by_date.contains_key(&tweet_date) { self.id_conversions.tweets_by_date.insert(tweet_date.clone(), HashMap::new()); @@ -770,10 +770,10 @@ impl TwitterCache { } pub fn display_id_for_tweet(&self, tweet: &Tweet) -> TweetId { let now = Local::now(); - let tweet_date = tweet.recieved_at.with_timezone(&now.timezone()); + let tweet_date = tweet.recieved_at.with_timezone(&Local); let bare_id = TweetId::Bare(tweet.internal_id); let maybe_dated_id = if now.year() == tweet_date.year() && now.month() == tweet_date.month() && now.day() == tweet_date.day() { - let date_string = format!("{:04}{:02}{:02}", tweet.recieved_at.year(), tweet.recieved_at.month(), tweet.recieved_at.day()); + let date_string = format!("{:04}{:02}{:02}", tweet_date.year(), tweet_date.month(), tweet_date.day()); let today_id = self.id_conversions.tweets_by_date_and_tweet_id.get(&date_string).and_then(|m| m.get(&tweet.internal_id)); today_id.map(|x| TweetId::Today(*x)) } else { |