Fix #146
This commit is contained in:
@ -221,7 +221,7 @@ impl Post {
|
||||
for post in post_list {
|
||||
let data = &post["data"];
|
||||
|
||||
let (rel_time, created) = time(data["created_utc"].as_i64().unwrap_or_default());
|
||||
let (rel_time, created) = time(data["created_utc"].as_f64().unwrap_or_default());
|
||||
let score = data["score"].as_i64().unwrap_or_default();
|
||||
let ratio: f64 = data["upvote_ratio"].as_f64().unwrap_or(1.0) * 100.0;
|
||||
let title = val(post, "title");
|
||||
@ -459,8 +459,8 @@ pub fn format_num(num: i64) -> String {
|
||||
}
|
||||
|
||||
// Parse a relative and absolute time from a UNIX timestamp
|
||||
pub fn time(created: i64) -> (String, String) {
|
||||
let time = OffsetDateTime::from_unix_timestamp(created);
|
||||
pub fn time(created: f64) -> (String, String) {
|
||||
let time = OffsetDateTime::from_unix_timestamp(created.round() as i64);
|
||||
let time_delta = OffsetDateTime::now_utc() - time;
|
||||
|
||||
// If the time difference is more than a month, show full date
|
||||
|
Reference in New Issue
Block a user