🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #14749

Re: Using Delta Times

#14749
From: Steve Schafer (TeamB)
Date: Fri, 06 Aug 1999 00:00
27 lines
1943 bytes
On Thu, 5 Aug 1999 12:45:07 -0500, "Bob Byron"
<forums.inprise.com@radit.com> wrote:

>I need to record relative date/times as opposed to absolute date/times.
>Instead of recording "10-Jan-1999", I need to record 45 days 5 hours 10
>minutes.  So, what is the best way to record a time of that nature?  Would
>the Date functions support something along that lines?  I know I can write a
>custom class to accomplish what I want, however, I don't want to reinvent
>the wheel.  Also, I could use the number of milliseconds, and probably will,

That's definitely the way to go.

>but that brings into question how to accurately represent 1 year, when you
>consider leap years.  Representing a year in milliseconds changes based on
>whether or not you have a leap year.

The same problem exists with months. You can't sensibly convert a
duration into "three years, seven months, two days," because the
latter representation is ambiguous. My first recommendation is don't
even try; stick with days, hours and minutes. If that's not an option
(because someone says you have to), then you will need to work out an
algorithm that explicitly resolves all of the ambiguities. Note that
you can even get into situations where the results are non-monotonic;
"two months and six days" can represent a duration which is _less_
than "two months and five days," depending on the start date.

-Steve
Technical Details
Message-ID: <37bb2bec.784827664@90.0.0.40>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <7ocidf$rm74@forums.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,6050dfab849b7a2f
X-Google-Attributes: gidf74b3,public
From: pandeng@telepath.com (Steve Schafer (TeamB))
Subject: Re: Using Delta Times
Date: 1999/08/06
Message-ID: <37bb2bec.784827664@90.0.0.40>
X-Deja-AN: 509388562
Content-Transfer-Encoding: 7bit
References: <7ocidf$rm74@forums.borland.com>
Content-Type: text/plain; charset=us-ascii
Organization: TeamB
Mime-Version: 1.0
Reply-To: pandeng@telepath.com
Newsgroups: borland.public.jbuilder.java.language