mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-01-01 05:16:05 +01:00
31422: better heuristic for timestamps in age function
This commit is contained in:
parent
a46aef7704
commit
711c103e77
3 changed files with 20 additions and 4 deletions
|
@ -1,3 +1,8 @@
|
|||
2013-05-29 Peter Stephenson <p.w.stephenson@ntlworld.com>
|
||||
|
||||
* 31422: Doc/Zsh/calsys.yo, Functions/Calendar/age: better
|
||||
heuristic for timestamps in use of :file feature.
|
||||
|
||||
2013-05-22 Peter Stephenson <p.w.stephenson@ntlworld.com>
|
||||
|
||||
* 31405: Doc/Zsh/options.yo: weasel words about
|
||||
|
|
|
@ -665,10 +665,15 @@ Instead of an explicit date and time, it's possible to use the
|
|||
modification time of a file as the date and time for either argument
|
||||
by introducing the file name with a colon:
|
||||
|
||||
example(print *+LPAR()e-age :file1-+RPAR())
|
||||
|
||||
matches all files created on the same day (24 hours starting from
|
||||
midnight) as tt(file1).
|
||||
|
||||
example(print *+LPAR()e-age :file1 :file2-+RPAR())
|
||||
|
||||
This matches all files modified no earlier than tt(file1) and
|
||||
no later than tt(file2).
|
||||
matches all files modified no earlier than tt(file1) and
|
||||
no later than tt(file2); precision here is to the nearest second.
|
||||
|
||||
texinode(Calendar Styles)(Calendar Utility Functions)(Calendar System User Functions)(Calendar Function System)
|
||||
sect(Styles)
|
||||
|
|
|
@ -33,6 +33,7 @@ zmodload -i zsh/parameter
|
|||
|
||||
autoload -Uz calendar_scandate
|
||||
|
||||
local timefmt
|
||||
local -a vals tmp
|
||||
|
||||
[[ -e $REPLY ]] || return 1
|
||||
|
@ -40,14 +41,19 @@ zstat -A vals +mtime -- $REPLY || return 1
|
|||
|
||||
if (( $# >= 1 )); then
|
||||
if [[ $1 = :* ]]; then
|
||||
zstat -A tmp -F "%Y/%m/%d" +mtime -- ${1#:} || return 1
|
||||
if (( $# > 1 )); then
|
||||
timefmt="%Y/%m/%d:%H:%M:%S"
|
||||
else
|
||||
timefmt="%Y/%m/%d"
|
||||
fi
|
||||
zstat -A tmp -F $timefmt +mtime -- ${1#:} || return 1
|
||||
local AGEREF=$tmp[1]
|
||||
else
|
||||
local AGEREF=$1
|
||||
fi
|
||||
# if 1 argument given, never use globally defined AGEREF2
|
||||
if [[ $2 = :* ]]; then
|
||||
zstat -A tmp -F "%Y/%m/%d" +mtime -- ${2#:} || return 1
|
||||
zstat -A tmp -F "%Y/%m/%d:%H:%M:%S" +mtime -- ${2#:} || return 1
|
||||
local AGEREF2=$tmp[1]
|
||||
else
|
||||
local AGEREF2=$2
|
||||
|
|
Loading…
Reference in a new issue