Răsfoiți Sursa

tau: fixed conversions

aggstam 3 ani în urmă
părinte
comite
60d31b677d

+ 3 - 5
bin/tau/tau-cli/src/drawdown.rs

@@ -18,7 +18,7 @@
 
 use std::collections::HashMap;
 
-use chrono::{Datelike, Duration, NaiveDate, NaiveDateTime, Utc};
+use chrono::{Datelike, Duration, NaiveDate, TimeZone, Utc};
 use colored::Colorize;
 use term_grid::{Cell, Direction, Filling, Grid, GridOptions};
 
@@ -111,11 +111,9 @@ pub fn drawdown(date: String, tasks: Vec<TaskInfo>, assignee: Option<String>) ->
                 .into_iter()
                 .filter(|t| {
                     // last event is always state stop
-                    let event_date = NaiveDateTime::from_timestamp_opt(
+                    let event_date = Utc.timestamp_nanos(
                         t.events.last().unwrap_or(&TaskEvent::default()).timestamp.0,
-                        0,
-                    )
-                    .unwrap();
+                    );
                     event_date.day() == day
                 })
                 .collect();

+ 4 - 5
bin/tau/tau-cli/src/filter.rs

@@ -21,7 +21,7 @@ use std::{
     process::exit,
 };
 
-use chrono::{Datelike, Local, NaiveDateTime, Utc};
+use chrono::{Datelike, Local, TimeZone, Utc};
 use log::error;
 use serde_json::Value;
 
@@ -72,7 +72,7 @@ pub fn apply_filter(tasks: &mut Vec<TaskInfo>, filter: &str) {
                     let year = year + (Utc::now().year() / 100) * 100;
                     tasks.retain(|task| {
                         let date = task.created_at;
-                        let task_date = NaiveDateTime::from_timestamp_opt(date, 0).unwrap().date();
+                        let task_date = Utc.timestamp_nanos(date).date_naive();
                         task_date.month() == month && task_date.year() == year
                     })
                 } else {
@@ -147,13 +147,12 @@ pub fn apply_filter(tasks: &mut Vec<TaskInfo>, filter: &str) {
                             Local::now().date_naive()
                         } else {
                             let due_date = due_as_timestamp(value).unwrap_or(0);
-                            NaiveDateTime::from_timestamp_opt(due_date, 0).unwrap().date()
+                            Utc.timestamp_nanos(due_date).date_naive()
                         };
 
                         tasks.retain(|task| {
                             let date = task.due.unwrap_or(0);
-                            let task_date =
-                                NaiveDateTime::from_timestamp_opt(date, 0).unwrap().date();
+                            let task_date = Utc.timestamp_nanos(date).date_naive();
 
                             match due_op {
                                 "not" => task_date != filter_date,

+ 1 - 3
bin/tau/taud/src/month_tasks.rs

@@ -91,9 +91,7 @@ impl MonthTasks {
 
     fn get_path(date: &NanoTimestamp, dataset_path: &Path) -> PathBuf {
         debug!(target: "tau", "MonthTasks::get_path()");
-        dataset_path
-            .join("month")
-            .join(Utc.timestamp_opt(date.0, 0).unwrap().format("%m%y").to_string())
+        dataset_path.join("month").join(Utc.timestamp_nanos(date.0).format("%m%y").to_string())
     }
 
     pub fn save(&self, dataset_path: &Path) -> TaudResult<()> {

+ 1 - 1
src/consensus/state.rs

@@ -885,7 +885,7 @@ mod tests {
             *TESTNET_GENESIS_HASH_BYTES,
             *TESTNET_INITIAL_DISTRIBUTION,
             true,
-        )?;
+        );
 
         let precision_diff = Float10::try_from(
             "10000000000000000000000000000000000000000000000000000000000000000000000000",