From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8921 invoked by alias); 10 Aug 2011 16:13:37 -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: 29670 Received: (qmail 23806 invoked from network); 10 Aug 2011 16:13:35 -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=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.google.com designates 209.85.220.171 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=GSTVjJbPt01VipJHE6bH6TndmYMeEN/9W7QTOSJm1WE=; b=wPXNbNJ4WfCorBkXE3eZdlopAvxT+Apeo1UyGXsi5lOAfm1kkc3iV0yiJty8aTioV9 3Fr9UG4m4pYYxGMl1Lu76lYCh7Et1OedRU6VUp2/Y4Cje7sRvruwHZ0WxWtPUebEaNNp Vip6fdEWv0rPwSbC7GtImBq23MFU+kKX/UA2I= MIME-Version: 1.0 In-Reply-To: <110810090819.ZM4843@torch.brasslantern.com> References: <20110810122137.3a3e4c00@pwslap01u.europe.root.pri> <20110810124120.0479177b@pwslap01u.europe.root.pri> <110810083017.ZM4722@torch.brasslantern.com> <20110810164113.3169c0a1@pwslap01u.europe.root.pri> <110810090819.ZM4843@torch.brasslantern.com> Date: Wed, 10 Aug 2011 18:13:31 +0200 Message-ID: Subject: Re: PATCH: zsh/datetime $EPOCHREALTIME From: Mikael Magnusson To: "Zsh Hackers' List" Content-Type: text/plain; charset=UTF-8 On 10 August 2011 18:08, Bart Schaefer wrote: > 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 ... 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