Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
vnotepad
Exa
提交
8b520edf
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,发现更多精彩内容 >>
提交
8b520edf
编写于
2月 09, 2015
作者:
B
Ben S
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Only display the year if it's last year
Otherwise, just display the hour and minute.
上级
bc7492e7
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
36 addition
and
25 deletion
+36
-25
src/column.rs
src/column.rs
+10
-10
src/file.rs
src/file.rs
+19
-12
src/options.rs
src/options.rs
+7
-3
未找到文件。
src/column.rs
浏览文件 @
8b520edf
...
...
@@ -8,7 +8,7 @@ use options::{SizeFormat, TimeType};
pub
enum
Column
{
Permissions
,
FileSize
(
SizeFormat
),
Timestamp
(
TimeType
),
Timestamp
(
TimeType
,
i64
),
Blocks
,
User
,
Group
,
...
...
@@ -43,15 +43,15 @@ impl Column {
/// to have a header row printed.
pub
fn
header
(
&
self
)
->
&
'static
str
{
match
*
self
{
Column
::
Permissions
=>
"Permissions"
,
Column
::
FileSize
(
_
)
=>
"Size"
,
Column
::
Timestamp
(
t
)
=>
t
.header
(),
Column
::
Blocks
=>
"Blocks"
,
Column
::
User
=>
"User"
,
Column
::
Group
=>
"Group"
,
Column
::
HardLinks
=>
"Links"
,
Column
::
Inode
=>
"inode"
,
Column
::
GitStatus
=>
"Git"
,
Column
::
Permissions
=>
"Permissions"
,
Column
::
FileSize
(
_
)
=>
"Size"
,
Column
::
Timestamp
(
t
,
_
)
=>
t
.header
(),
Column
::
Blocks
=>
"Blocks"
,
Column
::
User
=>
"User"
,
Column
::
Group
=>
"Group"
,
Column
::
HardLinks
=>
"Links"
,
Column
::
Inode
=>
"inode"
,
Column
::
GitStatus
=>
"Git"
,
}
}
}
...
...
src/file.rs
浏览文件 @
8b520edf
...
...
@@ -13,7 +13,7 @@ use pad::Alignment;
use
number_prefix
::{
binary_prefix
,
decimal_prefix
,
Prefixed
,
Standalone
,
PrefixNames
};
use
datetime
;
use
datetime
::
local
::
LocalDateTime
;
use
datetime
::
local
::
{
LocalDateTime
,
DatePiece
}
;
use
column
::{
Column
,
Cell
};
use
column
::
Column
::
*
;
...
...
@@ -99,15 +99,15 @@ impl<'a> File<'a> {
/// Get the data for a column, formatted as a coloured string.
pub
fn
display
<
U
:
Users
>
(
&
self
,
column
:
&
Column
,
users_cache
:
&
mut
U
)
->
Cell
{
match
*
column
{
Permissions
=>
self
.permissions_string
(),
FileSize
(
f
)
=>
self
.file_size
(
f
),
Timestamp
(
t
)
=>
self
.timestamp
(
t
),
HardLinks
=>
self
.hard_links
(),
Inode
=>
self
.inode
(),
Blocks
=>
self
.blocks
(),
User
=>
self
.user
(
users_cache
),
Group
=>
self
.group
(
users_cache
),
GitStatus
=>
self
.git_status
(),
Permissions
=>
self
.permissions_string
(),
FileSize
(
f
)
=>
self
.file_size
(
f
),
Timestamp
(
t
,
y
)
=>
self
.timestamp
(
t
,
y
),
HardLinks
=>
self
.hard_links
(),
Inode
=>
self
.inode
(),
Blocks
=>
self
.blocks
(),
User
=>
self
.user
(
users_cache
),
Group
=>
self
.group
(
users_cache
),
GitStatus
=>
self
.git_status
(),
}
}
...
...
@@ -303,8 +303,7 @@ impl<'a> File<'a> {
}
}
fn
timestamp
(
&
self
,
time_type
:
TimeType
)
->
Cell
{
let
format
=
date_format!
(
"{:Y} {:M} {2>:D} {2>:h}:{02>:m}"
);
fn
timestamp
(
&
self
,
time_type
:
TimeType
,
current_year
:
i64
)
->
Cell
{
// Need to convert these values from milliseconds into seconds.
let
time_in_seconds
=
match
time_type
{
...
...
@@ -314,6 +313,14 @@ impl<'a> File<'a> {
}
as
i64
/
1000
;
let
date
=
LocalDateTime
::
at
(
time_in_seconds
);
let
format
=
if
date
.year
()
==
current_year
{
date_format!
(
"{2>:D} {:M} {2>:h}:{02>:m}"
)
}
else
{
date_format!
(
"{2>:D} {:M} {4>:Y}"
)
};
Cell
::
paint
(
Blue
.normal
(),
format
.format
(
date
)
.as_slice
())
}
...
...
src/options.rs
浏览文件 @
8b520edf
...
...
@@ -12,6 +12,8 @@ use std::fmt;
use
getopts
;
use
natord
;
use
datetime
::
local
::{
LocalDateTime
,
DatePiece
};
use
self
::
Misfire
::
*
;
/// The *Options* struct represents a parsed version of the user's
...
...
@@ -422,16 +424,18 @@ impl Columns {
columns
.push
(
Group
);
}
let
current_year
=
LocalDateTime
::
now
()
.year
();
if
self
.time_types.modified
{
columns
.push
(
Timestamp
(
TimeType
::
FileModified
));
columns
.push
(
Timestamp
(
TimeType
::
FileModified
,
current_year
));
}
if
self
.time_types.created
{
columns
.push
(
Timestamp
(
TimeType
::
FileCreated
));
columns
.push
(
Timestamp
(
TimeType
::
FileCreated
,
current_year
));
}
if
self
.time_types.accessed
{
columns
.push
(
Timestamp
(
TimeType
::
FileAccessed
));
columns
.push
(
Timestamp
(
TimeType
::
FileAccessed
,
current_year
));
}
if
cfg!
(
feature
=
"git"
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录