mirror of
https://github.com/Llewellynvdm/exa.git
synced 2024-11-26 05:47:32 +00:00
Display dates with the host's timezone
Fixes #54 using the datetime crate's spiffy new time zone ability.
This commit is contained in:
parent
90c77ff3b4
commit
cc1d6aa5f1
68
Cargo.lock
generated
68
Cargo.lock
generated
@ -2,15 +2,15 @@
|
||||
name = "exa"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"ansi_term 0.5.2",
|
||||
"ansi_term 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bitflags 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"datetime 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"datetime 0.2.0",
|
||||
"getopts 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"git2 0.2.11 (git+https://github.com/alexcrichton/git2-rs.git)",
|
||||
"libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"locale 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"natord 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num_cpus 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num_cpus 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"number_prefix 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pad 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicode-width 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -20,6 +20,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ansi_term"
|
||||
version = "0.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
@ -27,20 +28,25 @@ version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "datetime"
|
||||
version = "0.1.7"
|
||||
name = "byteorder"
|
||||
version = "0.3.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "datetime"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"locale 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pad 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex_macros 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex_macros 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"tz 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gcc"
|
||||
version = "0.3.5"
|
||||
version = "0.3.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
@ -54,12 +60,12 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "git2"
|
||||
version = "0.2.11"
|
||||
source = "git+https://github.com/alexcrichton/git2-rs.git#49c7a7b3853626180e1767051ed53f0400140ff2"
|
||||
source = "git+https://github.com/alexcrichton/git2-rs.git#f63542fb5d58c138dd3ec32f78ab3f97e2251cfa"
|
||||
dependencies = [
|
||||
"bitflags 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libgit2-sys 0.2.14 (git+https://github.com/alexcrichton/git2-rs.git)",
|
||||
"url 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"url 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -70,10 +76,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
[[package]]
|
||||
name = "libgit2-sys"
|
||||
version = "0.2.14"
|
||||
source = "git+https://github.com/alexcrichton/git2-rs.git#49c7a7b3853626180e1767051ed53f0400140ff2"
|
||||
source = "git+https://github.com/alexcrichton/git2-rs.git#f63542fb5d58c138dd3ec32f78ab3f97e2251cfa"
|
||||
dependencies = [
|
||||
"libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libssh2-sys 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libssh2-sys 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libz-sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"openssl-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pkg-config 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -89,7 +95,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libssh2-sys"
|
||||
version = "0.1.23"
|
||||
version = "0.1.25"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -113,7 +119,7 @@ version = "0.1.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -136,7 +142,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "num"
|
||||
version = "0.1.24"
|
||||
version = "0.1.25"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"rand 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -145,7 +151,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "num_cpus"
|
||||
version = "0.2.5"
|
||||
version = "0.2.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -156,7 +162,7 @@ name = "number_prefix"
|
||||
version = "0.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"num 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -164,7 +170,7 @@ name = "openssl-sys"
|
||||
version = "0.6.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"gcc 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"gcc 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libressl-pnacl-sys 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pkg-config 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -201,15 +207,23 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "0.1.30"
|
||||
version = "0.1.33"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"regex-syntax 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "regex_macros"
|
||||
version = "0.1.17"
|
||||
version = "0.1.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"regex 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -225,6 +239,14 @@ dependencies = [
|
||||
"rand 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tz"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"byteorder 0.3.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-width"
|
||||
version = "0.1.1"
|
||||
@ -232,7 +254,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "url"
|
||||
version = "0.2.34"
|
||||
version = "0.2.35"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -9,7 +9,7 @@ name = "exa"
|
||||
[dependencies]
|
||||
ansi_term = "0.5.0"
|
||||
bitflags = "0.1"
|
||||
datetime = "0.1.3"
|
||||
datetime = "0.2.0"
|
||||
getopts = "0.2.1"
|
||||
libc = "*"
|
||||
locale = "0.1.2"
|
||||
|
@ -19,6 +19,8 @@ use number_prefix::{binary_prefix, decimal_prefix, Prefixed, Standalone, PrefixN
|
||||
|
||||
use datetime::local::{LocalDateTime, DatePiece};
|
||||
use datetime::format::{DateFormat};
|
||||
use datetime::zoned::{VariableOffset, TimeZone};
|
||||
|
||||
|
||||
/// With the **Details** view, the output gets formatted into columns, with
|
||||
/// each `Column` object showing some piece of information about the file,
|
||||
@ -128,6 +130,7 @@ pub struct Table<U> {
|
||||
|
||||
time: locale::Time,
|
||||
numeric: locale::Numeric,
|
||||
tz: VariableOffset,
|
||||
users: U,
|
||||
colours: Colours,
|
||||
current_year: i64,
|
||||
@ -140,6 +143,7 @@ impl Default for Table<MockUsers> {
|
||||
rows: Vec::new(),
|
||||
time: locale::Time::english(),
|
||||
numeric: locale::Numeric::english(),
|
||||
tz: VariableOffset::localtime().unwrap(),
|
||||
users: MockUsers::with_current_uid(0),
|
||||
colours: Colours::default(),
|
||||
current_year: 1234,
|
||||
@ -158,6 +162,7 @@ impl Table<OSUsers> {
|
||||
|
||||
time: locale::Time::load_user_locale().unwrap_or_else(|_| locale::Time::english()),
|
||||
numeric: locale::Numeric::load_user_locale().unwrap_or_else(|_| locale::Numeric::english()),
|
||||
tz: VariableOffset::localtime().unwrap(),
|
||||
users: OSUsers::empty_cache(),
|
||||
colours: colours,
|
||||
current_year: LocalDateTime::now().year(),
|
||||
@ -304,7 +309,7 @@ impl<U> Table<U> where U: Users {
|
||||
}
|
||||
|
||||
fn render_time(&self, timestamp: f::Time) -> Cell {
|
||||
let date = LocalDateTime::at(timestamp.0);
|
||||
let date = self.tz.at(LocalDateTime::at(timestamp.0));
|
||||
|
||||
let format = if date.year() == self.current_year {
|
||||
DateFormat::parse("{2>:D} {:M} {2>:h}:{02>:m}").unwrap()
|
||||
@ -313,7 +318,7 @@ impl<U> Table<U> where U: Users {
|
||||
DateFormat::parse("{2>:D} {:M} {5>:Y}").unwrap()
|
||||
};
|
||||
|
||||
Cell::paint(self.colours.date, &format.format(date, &self.time))
|
||||
Cell::paint(self.colours.date, &format.format(&date, &self.time))
|
||||
}
|
||||
|
||||
fn render_git_status(&self, git: f::Git) -> Cell {
|
||||
|
Loading…
Reference in New Issue
Block a user