Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
vnotepad
Exa
提交
b0da0c90
E
Exa
项目概览
vnotepad
/
Exa
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
Exa
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
b0da0c90
编写于
12月 17, 2018
作者:
A
ariasuni
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use correct metadata for created time
上级
35bf32ab
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
41 addition
and
42 deletion
+41
-42
src/fs/file.rs
src/fs/file.rs
+9
-17
src/output/render/mod.rs
src/output/render/mod.rs
+1
-0
src/output/render/times.rs
src/output/render/times.rs
+8
-3
src/output/table.rs
src/output/table.rs
+1
-0
src/output/time.rs
src/output/time.rs
+22
-22
未找到文件。
src/fs/file.rs
浏览文件 @
b0da0c90
...
...
@@ -5,6 +5,7 @@ use std::io::Error as IOError;
use
std
::
io
::
Result
as
IOResult
;
use
std
::
os
::
unix
::
fs
::{
MetadataExt
,
PermissionsExt
,
FileTypeExt
};
use
std
::
path
::{
Path
,
PathBuf
};
use
std
::
time
::{
UNIX_EPOCH
,
Duration
};
use
fs
::
dir
::
Dir
;
use
fs
::
fields
as
f
;
...
...
@@ -296,27 +297,18 @@ impl<'dir> File<'dir> {
}
/// This file’s last modified timestamp.
pub
fn
modified_time
(
&
self
)
->
f
::
Time
{
f
::
Time
{
seconds
:
self
.metadata
.mtime
(),
nanoseconds
:
self
.metadata
.mtime_nsec
()
}
pub
fn
modified_time
(
&
self
)
->
Duration
{
self
.metadata
.modified
()
.unwrap
()
.duration_since
(
UNIX_EPOCH
)
.unwrap
()
}
/// This file’s created timestamp.
pub
fn
created_time
(
&
self
)
->
f
::
Time
{
f
::
Time
{
seconds
:
self
.metadata
.ctime
(),
nanoseconds
:
self
.metadata
.ctime_nsec
()
}
/// This file’s last accessed timestamp.
pub
fn
accessed_time
(
&
self
)
->
Duration
{
self
.metadata
.accessed
()
.unwrap
()
.duration_since
(
UNIX_EPOCH
)
.unwrap
()
}
/// This file’s last accessed timestamp.
pub
fn
accessed_time
(
&
self
)
->
f
::
Time
{
f
::
Time
{
seconds
:
self
.metadata
.atime
(),
nanoseconds
:
self
.metadata
.atime_nsec
()
}
/// This file’s created timestamp.
pub
fn
created_time
(
&
self
)
->
Duration
{
self
.metadata
.created
()
.unwrap
()
.duration_since
(
UNIX_EPOCH
)
.unwrap
()
}
/// This file’s ‘type’.
...
...
src/output/render/mod.rs
浏览文件 @
b0da0c90
...
...
@@ -23,6 +23,7 @@ mod size;
pub
use
self
::
size
::
Colours
as
SizeColours
;
mod
times
;
pub
use
self
::
times
::
Render
as
TimeRender
;
// times does too
mod
users
;
...
...
src/output/render/times.rs
浏览文件 @
b0da0c90
use
datetime
::
TimeZone
;
use
ansi_term
::
Style
;
use
fs
::
fields
as
f
;
use
output
::
cell
::
TextCell
;
use
output
::
time
::
TimeFormat
;
impl
f
::
Time
{
pub
fn
render
(
self
,
style
:
Style
,
pub
trait
Render
{
fn
render
(
self
,
style
:
Style
,
tz
:
&
Option
<
TimeZone
>
,
format
:
&
TimeFormat
)
->
TextCell
;
}
impl
Render
for
std
::
time
::
Duration
{
fn
render
(
self
,
style
:
Style
,
tz
:
&
Option
<
TimeZone
>
,
format
:
&
TimeFormat
)
->
TextCell
{
...
...
src/output/table.rs
浏览文件 @
b0da0c90
...
...
@@ -12,6 +12,7 @@ use users::UsersCache;
use
style
::
Colours
;
use
output
::
cell
::
TextCell
;
use
output
::
render
::
TimeRender
;
use
output
::
time
::
TimeFormat
;
use
fs
::{
File
,
fields
as
f
};
use
fs
::
feature
::
git
::
GitCache
;
...
...
src/output/time.rs
浏览文件 @
b0da0c90
//! Timestamp formatting.
use
std
::
time
::
Duration
;
use
datetime
::{
LocalDateTime
,
TimeZone
,
DatePiece
,
TimePiece
};
use
datetime
::
fmt
::
DateFormat
;
use
locale
;
use
std
::
cmp
;
use
fs
::
fields
::
Time
;
/// Every timestamp in exa needs to be rendered by a **time format**.
/// Formatting times is tricky, because how a timestamp is rendered can
...
...
@@ -51,7 +51,7 @@ pub enum TimeFormat {
// timestamps are separate types.
impl
TimeFormat
{
pub
fn
format_local
(
&
self
,
time
:
Time
)
->
String
{
pub
fn
format_local
(
&
self
,
time
:
Duration
)
->
String
{
match
*
self
{
TimeFormat
::
DefaultFormat
(
ref
fmt
)
=>
fmt
.format_local
(
time
),
TimeFormat
::
ISOFormat
(
ref
iso
)
=>
iso
.format_local
(
time
),
...
...
@@ -60,7 +60,7 @@ impl TimeFormat {
}
}
pub
fn
format_zoned
(
&
self
,
time
:
Time
,
zone
:
&
TimeZone
)
->
String
{
pub
fn
format_zoned
(
&
self
,
time
:
Duration
,
zone
:
&
TimeZone
)
->
String
{
match
*
self
{
TimeFormat
::
DefaultFormat
(
ref
fmt
)
=>
fmt
.format_zoned
(
time
,
zone
),
TimeFormat
::
ISOFormat
(
ref
iso
)
=>
iso
.format_zoned
(
time
,
zone
),
...
...
@@ -128,8 +128,8 @@ impl DefaultFormat {
}
#[allow(trivial_numeric_casts)]
fn
format_local
(
&
self
,
time
:
Time
)
->
String
{
let
date
=
LocalDateTime
::
at
(
time
.
seconds
as
i64
);
fn
format_local
(
&
self
,
time
:
Duration
)
->
String
{
let
date
=
LocalDateTime
::
at
(
time
.
as_secs
()
as
i64
);
if
self
.is_recent
(
date
)
{
self
.date_and_time
.format
(
&
date
,
&
self
.locale
)
...
...
@@ -140,8 +140,8 @@ impl DefaultFormat {
}
#[allow(trivial_numeric_casts)]
fn
format_zoned
(
&
self
,
time
:
Time
,
zone
:
&
TimeZone
)
->
String
{
let
date
=
zone
.to_zoned
(
LocalDateTime
::
at
(
time
.
seconds
as
i64
));
fn
format_zoned
(
&
self
,
time
:
Duration
,
zone
:
&
TimeZone
)
->
String
{
let
date
=
zone
.to_zoned
(
LocalDateTime
::
at
(
time
.
as_secs
()
as
i64
));
if
self
.is_recent
(
date
)
{
self
.date_and_time
.format
(
&
date
,
&
self
.locale
)
...
...
@@ -154,16 +154,16 @@ impl DefaultFormat {
#[allow(trivial_numeric_casts)]
fn
long_local
(
time
:
Time
)
->
String
{
let
date
=
LocalDateTime
::
at
(
time
.
seconds
as
i64
);
fn
long_local
(
time
:
Duration
)
->
String
{
let
date
=
LocalDateTime
::
at
(
time
.
as_secs
()
as
i64
);
format!
(
"{:04}-{:02}-{:02} {:02}:{:02}"
,
date
.year
(),
date
.month
()
as
usize
,
date
.day
(),
date
.hour
(),
date
.minute
())
}
#[allow(trivial_numeric_casts)]
fn
long_zoned
(
time
:
Time
,
zone
:
&
TimeZone
)
->
String
{
let
date
=
zone
.to_zoned
(
LocalDateTime
::
at
(
time
.
seconds
as
i64
));
fn
long_zoned
(
time
:
Duration
,
zone
:
&
TimeZone
)
->
String
{
let
date
=
zone
.to_zoned
(
LocalDateTime
::
at
(
time
.
as_secs
()
as
i64
));
format!
(
"{:04}-{:02}-{:02} {:02}:{:02}"
,
date
.year
(),
date
.month
()
as
usize
,
date
.day
(),
date
.hour
(),
date
.minute
())
...
...
@@ -171,23 +171,23 @@ fn long_zoned(time: Time, zone: &TimeZone) -> String {
#[allow(trivial_numeric_casts)]
fn
full_local
(
time
:
Time
)
->
String
{
let
date
=
LocalDateTime
::
at
(
time
.
seconds
as
i64
);
fn
full_local
(
time
:
Duration
)
->
String
{
let
date
=
LocalDateTime
::
at
(
time
.
as_secs
()
as
i64
);
format!
(
"{:04}-{:02}-{:02} {:02}:{:02}:{:02}.{:09}"
,
date
.year
(),
date
.month
()
as
usize
,
date
.day
(),
date
.hour
(),
date
.minute
(),
date
.second
(),
time
.
nanoseconds
)
date
.hour
(),
date
.minute
(),
date
.second
(),
time
.
subsec_nanos
()
)
}
#[allow(trivial_numeric_casts)]
fn
full_zoned
(
time
:
Time
,
zone
:
&
TimeZone
)
->
String
{
fn
full_zoned
(
time
:
Duration
,
zone
:
&
TimeZone
)
->
String
{
use
datetime
::
Offset
;
let
local
=
LocalDateTime
::
at
(
time
.
seconds
as
i64
);
let
local
=
LocalDateTime
::
at
(
time
.
as_secs
()
as
i64
);
let
date
=
zone
.to_zoned
(
local
);
let
offset
=
Offset
::
of_seconds
(
zone
.offset
(
local
)
as
i32
)
.expect
(
"Offset out of range"
);
format!
(
"{:04}-{:02}-{:02} {:02}:{:02}:{:02}.{:09} {:+03}{:02}"
,
date
.year
(),
date
.month
()
as
usize
,
date
.day
(),
date
.hour
(),
date
.minute
(),
date
.second
(),
time
.
nanoseconds
,
date
.hour
(),
date
.minute
(),
date
.second
(),
time
.
subsec_nanos
()
,
offset
.hours
(),
offset
.minutes
()
.abs
())
}
...
...
@@ -214,8 +214,8 @@ impl ISOFormat {
}
#[allow(trivial_numeric_casts)]
fn
format_local
(
&
self
,
time
:
Time
)
->
String
{
let
date
=
LocalDateTime
::
at
(
time
.
seconds
as
i64
);
fn
format_local
(
&
self
,
time
:
Duration
)
->
String
{
let
date
=
LocalDateTime
::
at
(
time
.
as_secs
()
as
i64
);
if
self
.is_recent
(
date
)
{
format!
(
"{:02}-{:02} {:02}:{:02}"
,
...
...
@@ -229,8 +229,8 @@ impl ISOFormat {
}
#[allow(trivial_numeric_casts)]
fn
format_zoned
(
&
self
,
time
:
Time
,
zone
:
&
TimeZone
)
->
String
{
let
date
=
zone
.to_zoned
(
LocalDateTime
::
at
(
time
.
seconds
as
i64
));
fn
format_zoned
(
&
self
,
time
:
Duration
,
zone
:
&
TimeZone
)
->
String
{
let
date
=
zone
.to_zoned
(
LocalDateTime
::
at
(
time
.
as_secs
()
as
i64
));
if
self
.is_recent
(
date
)
{
format!
(
"{:02}-{:02} {:02}:{:02}"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录