mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-31 04:57:45 +00:00
time: Improve the l&f
This commit is contained in:
parent
c009e1bed8
commit
2b11d77395
3 changed files with 23 additions and 10 deletions
|
@ -247,7 +247,8 @@ fn stat(path: &Path, follow: bool) -> UResult<(FileTime, FileTime)> {
|
|||
}
|
||||
|
||||
const POSIX_LOCALE_FORMAT: &[time::format_description::FormatItem] = format_description!(
|
||||
"[weekday repr:short] [month repr:short] [day padding:space] [hour]:[minute]:[second] [year]"
|
||||
"[weekday repr:short] [month repr:short] [day padding:space] \
|
||||
[hour]:[minute]:[second] [year]"
|
||||
);
|
||||
|
||||
const ISO_8601_FORMAT: &[time::format_description::FormatItem] =
|
||||
|
@ -294,20 +295,27 @@ fn parse_date(s: &str) -> UResult<FileTime> {
|
|||
|
||||
// "%Y%m%d%H%M.%S" 15 chars
|
||||
const YYYYMMDDHHMM_DOT_SS_FORMAT: &[time::format_description::FormatItem] = format_description!(
|
||||
"[year repr:full][month repr:numerical padding:zero][day][hour][minute].[second]"
|
||||
"[year repr:full][month repr:numerical padding:zero]\
|
||||
[day][hour][minute].[second]"
|
||||
);
|
||||
|
||||
// "%Y%m%d%H%M" 12 chars
|
||||
const YYYYMMDDHHMM_FORMAT: &[time::format_description::FormatItem] =
|
||||
format_description!("[year repr:full][month repr:numerical padding:zero][day][hour][minute]");
|
||||
const YYYYMMDDHHMM_FORMAT: &[time::format_description::FormatItem] = format_description!(
|
||||
"[year repr:full][month repr:numerical padding:zero]\
|
||||
[day][hour][minute]"
|
||||
);
|
||||
|
||||
// "%y%m%d%H%M.%S" 13 chars
|
||||
const YYMMDDHHMM_DOT_SS_FORMAT: &[time::format_description::FormatItem] =
|
||||
format_description!("[year repr:last_two padding:none][month][day][hour][minute].[second]");
|
||||
const YYMMDDHHMM_DOT_SS_FORMAT: &[time::format_description::FormatItem] = format_description!(
|
||||
"[year repr:last_two padding:none][month][day]\
|
||||
[hour][minute].[second]"
|
||||
);
|
||||
|
||||
// "%y%m%d%H%M" 10 chars
|
||||
const YYMMDDHHMM_FORMAT: &[time::format_description::FormatItem] =
|
||||
format_description!("[year repr:last_two padding:none][month padding:zero][day padding:zero][hour repr:24 padding:zero][minute padding:zero]");
|
||||
const YYMMDDHHMM_FORMAT: &[time::format_description::FormatItem] = format_description!(
|
||||
"[year repr:last_two padding:none][month padding:zero][day padding:zero]\
|
||||
[hour repr:24 padding:zero][minute padding:zero]"
|
||||
);
|
||||
|
||||
fn parse_timestamp(s: &str) -> UResult<FileTime> {
|
||||
// TODO: handle error
|
||||
|
|
|
@ -26,7 +26,7 @@ wild = "2.0"
|
|||
# * optional
|
||||
itertools = { version="0.10.0", optional=true }
|
||||
thiserror = { version="1.0", optional=true }
|
||||
time = { version="<= 0.3.10", optional=true, features = ["formatting", "local-offset", "macros"] }
|
||||
time = { version="<= 0.3", optional=true, features = ["formatting", "local-offset", "macros"] }
|
||||
# * "problem" dependencies (pinned)
|
||||
data-encoding = { version="2.1", optional=true }
|
||||
data-encoding-macro = { version="0.1.12", optional=true }
|
||||
|
|
|
@ -734,7 +734,12 @@ where
|
|||
}
|
||||
|
||||
// match strftime "%Y-%m-%d %H:%M:%S.%f %z"
|
||||
const PRETTY_DATETIME_FORMAT: &[time::format_description::FormatItem] = format_description!("[year]-[month]-[day padding:zero] [hour]:[minute]:[second].[subsecond digits:9] [offset_hour sign:mandatory][offset_minute]");
|
||||
const PRETTY_DATETIME_FORMAT: &[time::format_description::FormatItem] = format_description!(
|
||||
"\
|
||||
[year]-[month]-[day padding:zero] \
|
||||
[hour]:[minute]:[second].[subsecond digits:9] \
|
||||
[offset_hour sign:mandatory][offset_minute]"
|
||||
);
|
||||
|
||||
pub fn pretty_time(sec: i64, nsec: i64) -> String {
|
||||
// sec == seconds since UNIX_EPOCH
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue