Chester Liu 4 سال پیش
والد
کامیت
31583691d5
2فایلهای تغییر یافته به همراه31 افزوده شده و 11 حذف شده
  1. 5 0
      src/fs/file.rs
  2. 26 11
      src/output/table.rs

+ 5 - 0
src/fs/file.rs

@@ -374,6 +374,11 @@ impl<'dir> File<'dir> {
         }
         }
     }
     }
 
 
+    #[cfg(windows)]
+    pub fn changed_time(&self) -> Option<SystemTime> {
+        return self.modified_time()
+    }
+
     /// This file’s last accessed timestamp, if available on this platform.
     /// This file’s last accessed timestamp, if available on this platform.
     pub fn accessed_time(&self) -> Option<SystemTime> {
     pub fn accessed_time(&self) -> Option<SystemTime> {
         self.metadata.accessed().ok()
         self.metadata.accessed().ok()

+ 26 - 11
src/output/table.rs

@@ -92,22 +92,18 @@ impl Columns {
         }
         }
 
 
         if self.time_types.modified {
         if self.time_types.modified {
-            #[cfg(unix)]
             columns.push(Column::Timestamp(TimeType::Modified));
             columns.push(Column::Timestamp(TimeType::Modified));
         }
         }
 
 
         if self.time_types.changed {
         if self.time_types.changed {
-            #[cfg(unix)]
             columns.push(Column::Timestamp(TimeType::Changed));
             columns.push(Column::Timestamp(TimeType::Changed));
         }
         }
 
 
         if self.time_types.created {
         if self.time_types.created {
-            #[cfg(unix)]
             columns.push(Column::Timestamp(TimeType::Created));
             columns.push(Column::Timestamp(TimeType::Created));
         }
         }
 
 
         if self.time_types.accessed {
         if self.time_types.accessed {
-            #[cfg(unix)]
             columns.push(Column::Timestamp(TimeType::Accessed));
             columns.push(Column::Timestamp(TimeType::Accessed));
         }
         }
 
 
@@ -125,7 +121,6 @@ impl Columns {
 pub enum Column {
 pub enum Column {
     Permissions,
     Permissions,
     FileSize,
     FileSize,
-    #[cfg(unix)]
     Timestamp(TimeType),
     Timestamp(TimeType),
     #[cfg(unix)]
     #[cfg(unix)]
     Blocks,
     Blocks,
@@ -179,7 +174,6 @@ impl Column {
         match self {
         match self {
             Self::Permissions   => "Permissions",
             Self::Permissions   => "Permissions",
             Self::FileSize      => "Size",
             Self::FileSize      => "Size",
-            #[cfg(unix)]
             Self::Timestamp(t)  => t.header(),
             Self::Timestamp(t)  => t.header(),
             #[cfg(unix)]
             #[cfg(unix)]
             Self::Blocks        => "Blocks",
             Self::Blocks        => "Blocks",
@@ -328,6 +322,7 @@ impl Environment {
     }
     }
 }
 }
 
 
+#[cfg(unix)]
 fn determine_time_zone() -> TZResult<TimeZone> {
 fn determine_time_zone() -> TZResult<TimeZone> {
     if let Ok(file) = env::var("TZ") {
     if let Ok(file) = env::var("TZ") {
         TimeZone::from_file(format!("/usr/share/zoneinfo/{}", file))
         TimeZone::from_file(format!("/usr/share/zoneinfo/{}", file))
@@ -337,6 +332,31 @@ fn determine_time_zone() -> TZResult<TimeZone> {
     }
     }
 }
 }
 
 
+#[cfg(windows)]
+fn determine_time_zone() -> TZResult<TimeZone> {
+    use datetime::zone::{FixedTimespan, FixedTimespanSet, StaticTimeZone, TimeZoneSource};
+    use std::borrow::Cow;
+
+    Ok(TimeZone(TimeZoneSource::Static(&StaticTimeZone {
+        name: "Unsupported",
+        fixed_timespans: FixedTimespanSet {
+            first: FixedTimespan {
+                offset: 0,
+                is_dst: false,
+                name: Cow::Borrowed("ZONE_A"),
+            },
+            rest: &[(
+                1206838800,
+                FixedTimespan {
+                    offset: 3600,
+                    is_dst: false,
+                    name: Cow::Borrowed("ZONE_B"),
+                },
+            )],
+        },
+    })))
+}
+
 lazy_static! {
 lazy_static! {
     static ref ENVIRONMENT: Environment = Environment::load_all();
     static ref ENVIRONMENT: Environment = Environment::load_all();
 }
 }
@@ -449,20 +469,15 @@ impl<'a, 'f> Table<'a> {
             Column::Octal => {
             Column::Octal => {
                 self.octal_permissions(file).render(self.theme.ui.octal)
                 self.octal_permissions(file).render(self.theme.ui.octal)
             }
             }
-
-            #[cfg(unix)]
             Column::Timestamp(TimeType::Modified)  => {
             Column::Timestamp(TimeType::Modified)  => {
                 file.modified_time().render(self.theme.ui.date, &self.env.tz, self.time_format)
                 file.modified_time().render(self.theme.ui.date, &self.env.tz, self.time_format)
             }
             }
-            #[cfg(unix)]
             Column::Timestamp(TimeType::Changed)   => {
             Column::Timestamp(TimeType::Changed)   => {
                 file.changed_time().render(self.theme.ui.date, &self.env.tz, self.time_format)
                 file.changed_time().render(self.theme.ui.date, &self.env.tz, self.time_format)
             }
             }
-            #[cfg(unix)]
             Column::Timestamp(TimeType::Created)   => {
             Column::Timestamp(TimeType::Created)   => {
                 file.created_time().render(self.theme.ui.date, &self.env.tz, self.time_format)
                 file.created_time().render(self.theme.ui.date, &self.env.tz, self.time_format)
             }
             }
-            #[cfg(unix)]
             Column::Timestamp(TimeType::Accessed)  => {
             Column::Timestamp(TimeType::Accessed)  => {
                 file.accessed_time().render(self.theme.ui.date, &self.env.tz, self.time_format)
                 file.accessed_time().render(self.theme.ui.date, &self.env.tz, self.time_format)
             }
             }