Skip to content
This is the development version of the documentation. It may change before the next release. See 0.6.x for the latest release.

DcSysTime

DcSysTime is a type representing a time on the EtherCAT distributed clock (Distributed Clock, DC). It is used with TransitionMode::SysTime, GpioOut::SysTimeEq, and the like.

In EtherCAT, there is a clock synchronized across all slaves (the distributed clock), and each device operates in sync with it. This time is a 64-bit counter in ns units, counted from 2000-01-01 00:00:00 (UTC).

DcSysTime is constructed from the current time, a UTC datetime, or raw ns.

let epoch = DcSysTime::ZERO;
let now = DcSysTime::now();
let at = DcSysTime::from_utc(Utc.with_ymd_and_hms(2025, 1, 1, 0, 0, 0).unwrap()).unwrap();
let raw = DcSysTime::from_nanos(1_000_000_000);
let ns: u64 = now.sys_time();
let utc = now.to_utc();
Operation Description
ZERO Epoch (2000-01-01 00:00:00 UTC)
now() Current time of the host
from_nanos(ns) Construct from ns elapsed since the epoch
from_utc(utc) Construct from a UTC datetime
sys_time() ns elapsed since the epoch
to_utc() Convert to a UTC datetime

DcSysTime defines operations that add and subtract time differences.

let future = DcSysTime::now() + Duration::from_millis(100);
let past = future - Duration::from_millis(50);
let elapsed: Duration = future - past;
let is_after: bool = future > past; // true
Operation Result Description
DcSysTime + Duration DcSysTime Add the specified duration
DcSysTime - Duration DcSysTime Subtract the specified duration
DcSysTime - DcSysTime Duration Difference between two times (Rust only)
Comparison (< / > / ==, etc.) bool Comparison (Rust / C# only)

Rust uses core::time::Duration for Duration, C# uses TimeSpan, and Python uses autd3.Duration. Python provides only addition and subtraction (applying a time difference via + / -); it does not have computing a time difference or comparison.