| View previous topic :: View next topic |
| Author |
Message |
Only me Guest
|
Posted: Thu Dec 07, 2006 2:52 pm Post subject: What is the Best Way to calculate hours differents? |
|
|
Hi, I have the current time, for example 22:45, and I want that
the program will calculate the time in another country where the
time is +5:30 hours relative to my time.
or, my current time is 2:35 in the morning, and I want to know
what is the time in a place where the relative time is -7:15
hours comparing to my time.
How can I calculete it? a piece of code will be nice :-)
Thanks! |
|
| Back to top |
|
 |
Hans Galema Guest
|
Posted: Thu Dec 07, 2006 5:24 pm Post subject: Re: What is the Best Way to calculate hours differents? |
|
|
Only me wrote:
| Quote: | Hi, I have the current time, for example 22:45, and I want that
the program will calculate the time in another country where the
time is +5:30 hours relative to my time.
|
For which countrys on earth the time differs other than multiples of
hours?
+5.00 is possible. Or +6:00. I never saw something like +5:30.
Hans. |
|
| Back to top |
|
 |
Alan Bellingham Guest
|
Posted: Thu Dec 07, 2006 5:50 pm Post subject: Re: What is the Best Way to calculate hours differents? |
|
|
Hans Galema <notused (AT) notused (DOT) nl> wrote:
| Quote: | Only me wrote:
Hi, I have the current time, for example 22:45, and I want that
the program will calculate the time in another country where the
time is +5:30 hours relative to my time.
For which countrys on earth the time differs other than multiples of
hours?
|
Oh, a few.
India is on +5:30, Burma on +6:30, Central Australia on +9:30
| Quote: | +5.00 is possible. Or +6:00. I never saw something like +5:30.
|
How about the Chatham Islands - +12:45! (And no, not -11:15, they're on
the same day as New Zealand just to the west.)
Similarly, the Line Islands, at +14 rather than -10.
Alan Bellingham
--
ACCU Conference: 11-14 April 2007 - Paramount Oxford Hotel |
|
| Back to top |
|
 |
Only me Guest
|
Posted: Thu Dec 07, 2006 6:02 pm Post subject: Re: What is the Best Way to calculate hours differents? |
|
|
| Quote: | You can assign both date-time and the timedifference to a TDateTime
instance and then subtract them to get the new date-time.
|
Thanks Hans, can you please just give me the name of the
commands that I need? Thanks
Only me. |
|
| Back to top |
|
 |
Thorsten Kettner Guest
|
Posted: Thu Dec 07, 2006 6:30 pm Post subject: Re: What is the Best Way to calculate hours differents? |
|
|
"Only me" <MeOnly (AT) mail (DOT) com> wrote:
| Quote: | Hi, I have the current time, for example 22:45, and I want
that the program will calculate the time in another country
where the time is +5:30 hours relative to my time.
or, my current time is 2:35 in the morning, and I want to know
what is the time in a place where the relative time is -7:15
hours comparing to my time.
How can I calculete it? a piece of code will be nice :-)
Thanks!
|
You can add fractions of a day to a TDateTime:
#include <SysUtils.hpp>
TDateTime RightNow = Now();
TDateTime NowPlusFiveAndAHalf = RightNow + 5.5 / 24.0;
ShowMessage(NowPlusFiveAndAHalf.TimeString()); |
|
| Back to top |
|
 |
Hans Galema Guest
|
Posted: Thu Dec 07, 2006 6:40 pm Post subject: Re: What is the Best Way to calculate hours differents? |
|
|
Alan Bellingham wrote:
Na. What a world!
Thanks for pointing out. Learned again something.
And for the question:
You can assign both date-time and the timedifference to a TDateTime
instance and then subtract them to get the new date-time.
Hans. |
|
| Back to top |
|
 |
MeOnly Guest
|
Posted: Thu Dec 07, 2006 7:06 pm Post subject: Re: What is the Best Way to calculate hours differents? |
|
|
Na... IT looks too much complicate.... but Thanks. |
|
| Back to top |
|
 |
Me Only Guest
|
Posted: Thu Dec 07, 2006 7:07 pm Post subject: Re: What is the Best Way to calculate hours differents? |
|
|
| Quote: | You can add fractions of a day to a TDateTime:
#include <SysUtils.hpp
TDateTime RightNow = Now();
TDateTime NowPlusFiveAndAHalf = RightNow + 5.5 / 24.0;
ShowMessage(NowPlusFiveAndAHalf.TimeString());
|
Thanks!  |
|
| Back to top |
|
 |
Alan Bellingham Guest
|
Posted: Thu Dec 07, 2006 7:45 pm Post subject: Re: What is the Best Way to calculate hours differents? |
|
|
Hans Galema <notused (AT) notused (DOT) nl> wrote:
| Quote: | Alan Bellingham wrote:
Oh, a few.
Na. What a world!
|
Wikipedia is your friend. It has a truly mind-boggling map of time
zones, and you'll find the most amazing mess in the mid Pacific.
Alan Bellingham
--
ACCU Conference: 11-14 April 2007 - Paramount Oxford Hotel |
|
| Back to top |
|
 |
Duane Hebert Guest
|
Posted: Thu Dec 07, 2006 7:53 pm Post subject: Re: What is the Best Way to calculate hours differents? |
|
|
"Only me" <MeOnly (AT) mail (DOT) com> wrote in message
news:4577e458$1 (AT) newsgroups (DOT) borland.com...
| Quote: |
Hi, I have the current time, for example 22:45, and I want that
the program will calculate the time in another country where the
time is +5:30 hours relative to my time.
or, my current time is 2:35 in the morning, and I want to know
what is the time in a place where the relative time is -7:15
hours comparing to my time.
How can I calculete it? a piece of code will be nice
|
If you're interested in something portable, you can look at boost date_time
libs.
http://boost.org/doc/html/date_time/examples.html#date_time.examples.time_math |
|
| Back to top |
|
 |
Thomas Maeder [TeamB] Guest
|
Posted: Thu Dec 07, 2006 10:30 pm Post subject: Re: What is the Best Way to calculate hours differents? |
|
|
Alan Bellingham <alan (AT) lspace (DOT) org> writes:
| Quote: | For which countrys on earth the time differs other than multiples of
hours?
Oh, a few.
India is on +5:30, Burma on +6:30, Central Australia on +9:30
|
Not to forget Newfoundland.
http://www.timetemperature.com/tzca/newfoundland_time_zone.shtml |
|
| Back to top |
|
 |
Nate Guest
|
Posted: Sat Dec 09, 2006 8:33 am Post subject: Re: What is the Best Way to calculate hours differents? |
|
|
Thomas Maeder [TeamB] wrote:
I would *never* do that! In fact it was my first thought.
Of course you could convert to UTC (GMT) and then convert to the target. |
|
| Back to top |
|
 |
|