Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Is it possible to get a 4-char year in WATCHFMT

On Feb 27,  5:02pm, rj wrote:
} On Fri 27 at 04:39 PM -0500, rj <rj@xxxxxxxxx> wrote:
} > "%D" in WATCHFMT prints a 2-char year. Is there a way one can get a
} > 4-char year? Does WATCHFMT take strftime sequences?
} Actually, I see on one of my logins I was able to do it this way:
} %D{%A      %Y-%m-%d}
} Though I don't remember what "%A" does, and it isn't listed as an available
} sequence in the "WATCHFMT" setion in man zshall.

Although the doc was never updated to say so, %D in WATCHFMT behaves the
same way as %D in PROMPT.  So you can follow it with a strftime format
enclosed in curly braces.  It also supports the zsh format extensions
described for prompt escapes.

It's been that way for at least 16 years without ever getting doc'd.

diff --git a/Doc/Zsh/params.yo b/Doc/Zsh/params.yo
index 273be21..d044f87 100644
--- a/Doc/Zsh/params.yo
+++ b/Doc/Zsh/params.yo
@@ -1548,6 +1548,12 @@ The date in `var(mm)tt(/)var(dd)tt(/)var(yy)' format.
 The date in `var(yy)tt(-)var(mm)tt(-)var(dd)' format.
+The date formatted as var(string) using the tt(strftime) function, with
+zsh extensions as described by
+ifzman(EXPANSION OF PROMPT SEQUENCES in zmanref(zshmisc))\
+ifnzman(noderef(Prompt Expansion)).
 Specifies a ternary expression.
 The character following the var(x) is

Messages sorted by: Reverse Date, Date, Thread, Author