Discussion:
Calc time difference between two date/time/zones
(too old to reply)
battles
2008-10-16 20:32:11 UTC
Permalink
I have been searching and cannot find a way to determine the time
between two date/time/zones as shown below. Does anyone have a
routine that can do this easily without having to manually convert
everything to gmt? Thanks.

16 Oct 2008 07:57:01 -0500
16 Oct 2008 20:58:59 +0800
-----------------------------------------
= 4 seconds


15 Oct 2008 07:57:01 -0500
16 Oct 2008 01:58:59 +0800
-----------------------------------------
= 5 hrs 4 secs
Kenneth Porter
2008-10-16 21:52:19 UTC
Permalink
Post by battles
I have been searching and cannot find a way to determine the time
between two date/time/zones as shown below. Does anyone have a
routine that can do this easily without having to manually convert
everything to gmt? Thanks.
You picked two "simple" time zones. Will it always be those two? If not,
you're better off using a library routine to convert them to UTC for
arithemetic, as time zones can get very strange. Daylight Saving Time will
make it very complicated when you're near a DST transition.
battles
2008-10-17 13:07:03 UTC
Permalink
Post by Kenneth Porter
Post by battles
I have been searching and cannot find a way to determine the time
between two date/time/zones as shown below. Does anyone have a
routine that can do this easily without having to manually convert
everything to gmt? Thanks.
You picked two "simple" time zones. Will it always be those two? If not,
you're better off using a library routine to convert them to UTC for
arithemetic, as time zones can get very strange. Daylight Saving Time will
make it very complicated when you're near a DST transition.
This is what I am afraid of. It could be any time zone. Do you
know of a
library routine that does this?
David Kerber
2008-10-17 13:29:18 UTC
Permalink
In article <8301ddd9-29cb-41dd-9f28-38109f4b7e97
@p59g2000hsd.googlegroups.com>, ***@mailinator.com says...
Post by battles
Post by Kenneth Porter
Post by battles
I have been searching and cannot find a way to determine the time
between two date/time/zones as shown below. Does anyone have a
routine that can do this easily without having to manually convert
everything to gmt? Thanks.
You picked two "simple" time zones. Will it always be those two? If not,
you're better off using a library routine to convert them to UTC for
arithemetic, as time zones can get very strange. Daylight Saving Time will
make it very complicated when you're near a DST transition.
This is what I am afraid of. It could be any time zone. Do you
know of a
library routine that does this?
Will datediff not handle this directly (I haven't tried it)? If not,
then it should work if you convert them to GMT first, and then use
Datediff on those values.
--
/~\ The ASCII
\ / Ribbon Campaign
X Against HTML
/ \ Email!

Remove the ns_ from if replying by e-mail (but keep posts in the
newsgroups if possible).
battles
2008-10-17 21:04:46 UTC
Permalink
On Oct 17, 8:29 am, David Kerber
Post by David Kerber
In article <8301ddd9-29cb-41dd-9f28-38109f4b7e97
@p59g2000hsd.googlegroups.com>, ***@mailinator.com says...
Post by battles
Post by Kenneth Porter
Post by battles
I have been searching and cannot find a way to determine the time
between two date/time/zones as shown below. Does anyone have a
routine that can do this easily without having to manually convert
everything to gmt? Thanks.
You picked two "simple" time zones. Will it always be those two? If not,
you're better off using a library routine to convert them to UTC for
arithemetic, as time zones can get very strange. Daylight Saving Time will
make it very complicated when you're near a DST transition.
This is what I am afraid of. It could be any time zone. Do you
know of a
library routine that does this?
Will datediff not handle this directly (I haven't tried it)? If not,
then it should work if you convert them to GMT first, and then use
Datediff on those values.
--
/~\ The ASCII
\ / Ribbon Campaign
X Against HTML
/ \ Email!
Remove the ns_ from if replying by e-mail (but keep posts in the
newsgroups if possible).
It seems to only do dates. I am thinking of just converting
everything with DecodeTime and DecodeDate to seconds and then back to
time after subtracting. I was hoping that there was some kind of
library that you could pass 2 date/time/timezones to and get the
difference back. Thanks.
Dr J R Stockton
2008-10-18 12:01:04 UTC
Permalink
In comp.lang.pascal.delphi.misc message <c55d89ca-5419-4600-9c40-
b07a568
Post by battles
I have been searching and cannot find a way to determine the time
between two date/time/zones as shown below.
NO. Those are not time zones, they are time offsets. Time Zones do
not change seasonally.
Post by battles
Does anyone have a
routine that can do this easily without having to manually convert
everything to gmt? Thanks.
16 Oct 2008 07:57:01 -0500
16 Oct 2008 20:58:59 +0800
-----------------------------------------
= 4 seconds
15 Oct 2008 07:57:01 -0500
16 Oct 2008 01:58:59 +0800
-----------------------------------------
= 5 hrs 4 secs
To subtract those, firstly subtract the date and time treating them as
UTC or your-local, then correct by the difference in offset. Since
days and months are of variable lengths, the result is not technically
meaningful if expressed in any unit greater than hours. If the task
is administrative and requires larger units, look up the applicable
definition.

Alternatively, convert each Date/Time to TDateTime, and adjust the
offset to get a UTC TDateTime; then subtract those.

For the actual differencing, subtract TDateTimes, and treat the result
as a float of days.

For the difference between date/times at different known PLACES, you
want the Summer Time Rules and the Standard Offset - which can be
combined in TZ strings. There is code for this in dateunit.zip and/or
dateutys.pas, via <URL:http://www.merlyn.demon.co.uk/programs/>.

--
(c) John Stockton, near London, UK. Posting with Google.
Mail: J.R.""""""""@physics.org or (better) via Home Page at
Web: <URL:http://www.merlyn.demon.co.uk/>
FAQish topics, acronyms, links, etc.; Date, Delphi, JavaScript, ....|
Dr J R Stockton
2008-10-17 15:35:58 UTC
Permalink
In comp.lang.pascal.delphi.misc message <c55d89ca-5419-4600-9c40-b07a568
Post by battles
I have been searching and cannot find a way to determine the time
between two date/time/zones as shown below.
NO. Those are not time zones, they ate time offsets. Time Zones do not
change seasonally.
Post by battles
Does anyone have a
routine that can do this easily without having to manually convert
everything to gmt? Thanks.
16 Oct 2008 07:57:01 -0500
16 Oct 2008 20:58:59 +0800
-----------------------------------------
= 4 seconds
15 Oct 2008 07:57:01 -0500
16 Oct 2008 01:58:59 +0800
-----------------------------------------
= 5 hrs 4 secs
To subtract those, firstly subtract the date and time treating them as
UTC or your-local, then correct by the difference in offset. Since days
and months are of variable lengths, the result is not technically
meaningful if expressed in any unit greater than hours. If the task is
administrative and requires larger units, look up the applicable
definition.

For the actual differencing, subtract TDateTimes, and treat the result
as a float of days.

For the difference between date/times at different known PLACES, you
want the Summer Time Rules and the Standard Offset - which can be
combined in TZ strings. There is code for this in dateunit.zip and/or
dateutys.pas, via sig line 3.
--
(c) John Stockton, nr London UK. ?@merlyn.demon.co.uk DOS 3.3, 6.20; WinXP.
Web <URL:http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms & links.
PAS EXE TXT ZIP via <URL:http://www.merlyn.demon.co.uk/programs/00index.htm>
My DOS <URL:http://www.merlyn.demon.co.uk/batfiles.htm> - also batprogs.htm.
Continue reading on narkive:
Search results for 'Calc time difference between two date/time/zones' (Questions and Answers)
4
replies
Any information about orogenesis?
started 2006-08-01 05:06:44 UTC
earth sciences & geology
Loading...