From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: zsh-workers@zsh.org
Subject: Re: Missing "--" in the "age" function
Date: Wed, 22 May 2013 21:00:48 +0100 [thread overview]
Message-ID: <20130522210048.04db0bfb@pws-pc.ntlworld.com> (raw)
In-Reply-To: <20130522094601.4bdd8fbe@pwslap01u.europe.root.pri>
On Wed, 22 May 2013 09:46:01 +0100
Peter Stephenson <p.stephenson@samsung.com> wrote:
> Maybe the most convenient thing is if you give one :file argument it
> uses the date, and if there is a second argument it uses the date and
> time for both?
diff --git a/Doc/Zsh/calsys.yo b/Doc/Zsh/calsys.yo
index b3eb454..7dc51ab 100644
--- a/Doc/Zsh/calsys.yo
+++ b/Doc/Zsh/calsys.yo
@@ -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)
diff --git a/Functions/Calendar/age b/Functions/Calendar/age
index c636bdf..17cf4d1 100644
--- a/Functions/Calendar/age
+++ b/Functions/Calendar/age
@@ -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
--
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
prev parent reply other threads:[~2013-05-22 20:01 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-21 11:53 Stephane Chazelas
2013-05-21 15:19 ` Peter Stephenson
2013-05-21 19:10 ` Stephane Chazelas
2013-05-22 8:46 ` Peter Stephenson
2013-05-22 19:21 ` Stephane Chazelas
2013-05-22 20:00 ` Peter Stephenson [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130522210048.04db0bfb@pws-pc.ntlworld.com \
--to=p.w.stephenson@ntlworld.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).