From bug-request at octave dot org Sat Jan 7 16:53:04 2006 Subject: Re: etime in the new year From: Stefan van der Walt To: Keith Goodman Cc: bug at octave dot org Date: Sun, 8 Jan 2006 01:00:41 +0200 I saw formulas to calculate this thing in popular science magazines before (Scientific American?). I'm sure there must be a relatively simple way to accomplish this? Cheers Stéfan On Tue, Jan 03, 2006 at 12:29:16PM -0600, Keith Goodman wrote: > The function etime (elapsed time in seconds) returns an error when you > compare times with different years. From the code > > if (t1 (1) != t0 (1)) > error ("etime: can't handle timings over year boundaries yet"); > endif > > Is that because it's painful to deal with leap years? What's the best fix? > > (1) Write a separate function to find if a year is a leap year. > (2) Determine if a year is a leap year inside etime. > (3) Bring over datenum from octave-forge and modify it to handle leap > years and then use it for year, month, and day differences but not > fractional parts of days. ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------