Skip to content

Commit

Permalink
use chrono
Browse files Browse the repository at this point in the history
  • Loading branch information
birkenfeld committed Oct 3, 2024
1 parent e7f0f6b commit f63271a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ license = "MIT/Apache-2.0"
description = "Client for the Beckhoff Automation Device Specification protocol for PLCs"
repository = "https://github.com/birkenfeld/ads-rs"
keywords = ["Beckhoff", "ADS", "automation", "device", "PLC"]
rust-version = "1.63"

[dependencies]
byteorder = "1.5.0"
Expand All @@ -20,6 +21,6 @@ once_cell = "1.19.0"
parse_int = "0.6.0"
quick-xml = "0.36.1"
regex = "<1.10.0"
chrono = "0.4.38"
clap = { version = "3.2.25", features = ["derive"] }
strum = { version = "0.26.3", features = ["derive"] }
time = { version = "<0.3.18", features = ["formatting"] }
6 changes: 3 additions & 3 deletions examples/adstool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use parse_int::parse;
use clap::{Parser, Subcommand, ArgGroup, AppSettings};
use strum::EnumString;
use quick_xml::{events::Event, name::QName};
use time::OffsetDateTime;
use chrono::{DateTime, Utc};

#[derive(Parser, Debug)]
#[clap(disable_help_subcommand = true)]
Expand Down Expand Up @@ -769,10 +769,10 @@ fn hexdump(mut data: &[u8]) {
const EPOCH_OFFSET: i64 = 11644473600;

/// Convert Windows FILETIME to DateTime
fn convert_filetime(ft: i64) -> Option<OffsetDateTime> {
fn convert_filetime(ft: i64) -> Option<DateTime<Utc>> {
if ft == 0 { return None; }
let unix_ts = ft / 10_000_000 - EPOCH_OFFSET;
OffsetDateTime::from_unix_timestamp(unix_ts).ok()
DateTime::from_timestamp(unix_ts, 0)
}

/// Format a GUID.
Expand Down

0 comments on commit f63271a

Please sign in to comment.