Filetime

Struct Filetime 

Source
pub struct Filetime { /* private fields */ }
Expand description

Simplifies handling Windows filetime dates. Use only with UTC dates as it does not take time zones into account. Eliminates the need to use the chrono library. Its more complex than WinFiletime and uses more space, but its much faster when getting date parameters like hour,minute,day… as it parses the date when created.

use forensic_rs::prelude::*;
assert_eq!("01-01-1601 00:00:00", format!("{:?}", Filetime::new(0)));
assert_eq!("01-01-1605 00:00:00", format!("{:?}", Filetime::new(1262304000000000)));
assert_eq!("14-11-1999 18:27:59", format!("{:?}", Filetime::new(125870776790000000)));
assert_eq!("14-11-2000 18:27:59.001", format!("{:?}", Filetime::new(126187000790010000)));
assert_eq!(2000, Filetime::new(126187000790010000).year());
assert_eq!(100, Filetime::new(126187000790000001).nanoseconds());

Implementations§

Source§

impl Filetime

Source

pub fn new(timestap: u64) -> Self

Makes a new Filetime from windows u64 filetime

Source

pub fn with_ymd_and_hms( year: u16, month: u8, day: u8, hour: u8, minute: u8, second: u8, nanos: u32, ) -> Self

Make a new Filetime from year, month, day, time components assuming UTC.

Source

pub fn year(&self) -> u16

Returns the year number

use forensic_rs::prelude::*;
let time = Filetime::new(125963224790010000); // 29-02-2000 18:27:59.001
assert_eq!(2000, time.year());
Source

pub fn month(&self) -> u8

Returns the month number

use forensic_rs::prelude::*;
let time = Filetime::new(125963224790010000); // 29-02-2000 18:27:59.001
assert_eq!(2, time.month());
Source

pub fn day(&self) -> u8

Returns the day number

use forensic_rs::prelude::*;
let time = Filetime::new(125963224790010000); // 29-02-2000 18:27:59.001
assert_eq!(29, time.day());
Source

pub fn hour(&self) -> u8

Returns the hour number

use forensic_rs::prelude::*;
let time = Filetime::new(125963224790010000); // 29-02-2000 18:27:59.001
assert_eq!(18, time.hour());
Source

pub fn minute(&self) -> u8

Returns the minute number

use forensic_rs::prelude::*;
let time = Filetime::new(125963224790010000); // 29-02-2000 18:27:59.001
assert_eq!(27, time.minute());
Source

pub fn second(&self) -> u8

Returns the second number

use forensic_rs::prelude::*;
let time = Filetime::new(125963224790010000); // 29-02-2000 18:27:59.001
assert_eq!(59, time.second());
Source

pub fn millis(&self) -> u32

Returns the second number

use forensic_rs::prelude::*;
let time = Filetime::new(125963224790010000); // 29-02-2000 18:27:59.001
assert_eq!(1, time.millis());
Source

pub fn nanoseconds(&self) -> u32

Returns the nanoseconds number

use forensic_rs::prelude::*;
let time = Filetime::new(125963224790010000); // 29-02-2000 18:27:59.001
assert_eq!(1000000, time.nanoseconds());
Source

pub fn filetime(&self) -> u64

Returns the original filetime since 1601

use forensic_rs::prelude::*;
let time = Filetime::new(125963224790010000); // 29-02-2000 18:27:59.001
assert_eq!(125963224790010000, time.filetime());
Source

pub fn duration_since(&self, earlier: SystemTime) -> Result<Duration, Duration>

Returns the amount of time elapsed from an earlier point in time.

This function may fail because measurements taken earlier are not guaranteed to always be before later measurements (due to anomalies such as the system clock being adjusted either forwards or backwards). Instant can be used to measure elapsed time without this risk of failure.

If successful, Ok(Duration) is returned where the duration represents the amount of time elapsed from the specified measurement to this one.

Returns an Err if earlier is later than self, and the error contains how far from self the time is.

Trait Implementations§

Source§

impl Add<Duration> for Filetime

Source§

type Output = Filetime

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Duration) -> Self::Output

Performs the + operation. Read more
Source§

impl AddAssign<Duration> for Filetime

Source§

fn add_assign(&mut self, rhs: Duration)

Performs the += operation. Read more
Source§

impl Clone for Filetime

Source§

fn clone(&self) -> Filetime

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Filetime

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Filetime

Source§

fn default() -> Filetime

Returns the “default value” for a type. Read more
Source§

impl Display for Filetime

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<&Filetime> for SystemTime

Source§

fn from(val: &Filetime) -> Self

Converts to this type from the input type.
Source§

impl From<Filetime> for SystemTime

Source§

fn from(val: Filetime) -> Self

Converts to this type from the input type.
Source§

impl Ord for Filetime

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Filetime

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Filetime

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Sub<Duration> for Filetime

Source§

type Output = Filetime

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Duration) -> Self::Output

Performs the - operation. Read more
Source§

impl Copy for Filetime

Source§

impl Eq for Filetime

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.