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

Re: PATCH: zsh/datetime $EPOCHREALTIME

On 10 August 2011 18:08, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Aug 10,  4:41pm, Peter Stephenson wrote:
> }
> } On Wed, 10 Aug 2011 08:30:17 -0700
> } Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> } > Allow the user to apply typeset to EPOCHSECONDS.  If it's an int,
> } > it is as it is now.  If it's a float, what you called EPOCHREALTIME.
> } > If an array, elements for seconds and nanoseconds.  If a hash, the
> } > keys are tv_sec and tv_nsec like a timespec (convert from tv_usec
> } > when using gettimeofday).
> }
> } That's the trick I did with SECONDS, but a utility library like
> } zsh/datetime might be called in lots of different places and
> } come a cropper if the type is wrong (e.g. supplying a float to
> } strftime screws up), so I thought it would be better to minimise the
> } assumptions needed.
> Good point regarding overloading EPOCHSECONDS.  So, introduce a new
> variable EPOCHTIMESPEC (or just EPOCHTIME, I suppose).
> Regarding Mikael's question ... is there any way for the getfn of an
> array to know what array element has been accessed?  E.g. could the
> function update the time only when the entire array or the first
> (seconds) element is accessed, and return the previous value when
> the nanoseconds is accessed?
> If not, he's right, you'd always have to copy it (which is probably
> not a big deal if you're already interested in each bit separately).
> for sec nsec in $EPOCHTIME; do ...

Also, since we're dealing with nanoseconds it's nice if we don't spend
too many cycles mucking about, I know that is quite an optimistic
statement when talking about zsh, but still ;).

Mikael Magnusson

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