From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10347 invoked by alias); 10 Aug 2011 16:08:54 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 29669 Received: (qmail 13952 invoked from network); 10 Aug 2011 16:08:43 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <110810090819.ZM4843@torch.brasslantern.com> Date: Wed, 10 Aug 2011 09:08:19 -0700 In-reply-to: <20110810164113.3169c0a1@pwslap01u.europe.root.pri> Comments: In reply to Peter Stephenson "Re: PATCH: zsh/datetime $EPOCHREALTIME" (Aug 10, 4:41pm) References: <20110810122137.3a3e4c00@pwslap01u.europe.root.pri> <20110810124120.0479177b@pwslap01u.europe.root.pri> <110810083017.ZM4722@torch.brasslantern.com> <20110810164113.3169c0a1@pwslap01u.europe.root.pri> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: "Zsh Hackers' List" Subject: Re: PATCH: zsh/datetime $EPOCHREALTIME MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Aug 10, 4:41pm, Peter Stephenson wrote: } } On Wed, 10 Aug 2011 08:30:17 -0700 } Bart Schaefer 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 ...