|
|
@@ -5,9 +5,10 @@ extern crate xml;
|
|
|
use chrono::DateTime;
|
|
|
use chrono::TimeZone;
|
|
|
use chrono::Utc;
|
|
|
+use chrono::Duration;
|
|
|
use std::fs::File;
|
|
|
use std::io::BufReader;
|
|
|
-use std::time::Duration;
|
|
|
+use std::time::Duration as stdDuration;
|
|
|
|
|
|
use xml::reader::{EventReader, XmlEvent};
|
|
|
|
|
|
@@ -38,6 +39,21 @@ impl Track {
|
|
|
}
|
|
|
sum
|
|
|
}
|
|
|
+
|
|
|
+ fn time(&self) -> chrono::Duration {
|
|
|
+ // let timespan = &self.points[0].time.signed_duration_since(self.points[1].time);
|
|
|
+ let mut sum = Duration::from_std(stdDuration::new(0,0)).unwrap();
|
|
|
+ let mut prev_time = &self.points[0].time;
|
|
|
+
|
|
|
+ for pt in &self.points {
|
|
|
+ let timespan = prev_time.signed_duration_since(pt.time);
|
|
|
+ sum = sum.checked_sub(×pan).unwrap();
|
|
|
+ prev_time = &pt.time;
|
|
|
+
|
|
|
+ }
|
|
|
+ sum
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
fn dist(p1: &Point, p2: &Point) -> f64 {
|
|
|
@@ -142,6 +158,7 @@ fn main() {
|
|
|
// trk.points = Vec::new();
|
|
|
// trk.points = points;
|
|
|
println!("{:?}", trk.len());
|
|
|
+ println!("{:?}", trk.time());
|
|
|
|
|
|
|
|
|
|