/// Attempts to convert to a chrono UTC date time
Attempts to convert to a chrono UTC date time
Attempts to convert to a chrono UTC date time
pub fn to_datetime(&self) -> Option<DateTime<Utc>> {
        // see https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-dosdatetimetofiletime
        let date = match {
            // bits 0-4: day of the month (1-31)
            let d = (self.date & 0b1111_1) as u32;
            // bits 5-8: month (1 = january, 2 = february and so on)
            let m = ((self.date >> 5) & 0b1111) as u32;
            // bits 9-15: year offset from 1980
            let y = ((self.date >> 9) + 1980) as i32;
            Utc.ymd_opt(y, m, d)
        } {
            LocalResult::Single(date) => date,
            _ => return None,
        };
        // bits 0-4: second divided by 2
        let s = (self.time & 0b1111_1) as u32 * 2;
        // bits 5-10: minute (0-59)
        let m = (self.time >> 5 & 0b1111_11) as u32;
        // bits 11-15: hour (0-23 on a 24-hour clock)
        let h = (self.time >> 11) as u32;
        date.and_hms_opt(h, m, s)
    }
pub fn to_datetime ( & self ) -> Option < DateTime < Utc > > { // see https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-dosdatetimetofiletime let date = match { // bits 0-4: day of the month (1-31) let d = ( self . date & 0b1111_1 ) as u32 ; // bits 5-8: month (1 = january, 2 = february and so on) let m = ( ( self . date >> 5 ) & 0b1111 ) as u32 ; // bits 9-15: year offset from 1980 let y = ( ( self . date >> 9 ) + 1980 ) as i32 ; Utc . ymd_opt ( y , m , d ) } { LocalResult :: Single ( date ) => date , _ => return None , } ; // bits 0-4: second divided by 2 let s = ( self . time & 0b1111_1 ) as u32 * 2 ; // bits 5-10: minute (0-59) let m = ( self . time >> 5 & 0b1111_11 ) as u32 ; // bits 11-15: hour (0-23 on a 24-hour clock) let h = ( self . time >> 11 ) as u32 ; date . and_hms_opt ( h , m , s ) }
Attempts to convert to a chrono UTC date time
Attempts to convert to a chrono UTC date time
&self