BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

What is the Best Way to calculate hours differents?

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Language C++)
View previous topic :: View next topic  
Author Message
Only me
Guest





PostPosted: Thu Dec 07, 2006 2:52 pm    Post subject: What is the Best Way to calculate hours differents? Reply with 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!
Back to top
Hans Galema
Guest





PostPosted: Thu Dec 07, 2006 5:24 pm    Post subject: Re: What is the Best Way to calculate hours differents? Reply with quote



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





PostPosted: Thu Dec 07, 2006 5:50 pm    Post subject: Re: What is the Best Way to calculate hours differents? Reply with quote



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





PostPosted: Thu Dec 07, 2006 6:02 pm    Post subject: Re: What is the Best Way to calculate hours differents? Reply with quote

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 Smile

Only me.
Back to top
Thorsten Kettner
Guest





PostPosted: Thu Dec 07, 2006 6:30 pm    Post subject: Re: What is the Best Way to calculate hours differents? Reply with quote

"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





PostPosted: Thu Dec 07, 2006 6:40 pm    Post subject: Re: What is the Best Way to calculate hours differents? Reply with quote

Alan Bellingham wrote:

Quote:
Oh, a few.

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





PostPosted: Thu Dec 07, 2006 7:06 pm    Post subject: Re: What is the Best Way to calculate hours differents? Reply with quote

Quote:
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

Na... IT looks too much complicate.... but Thanks.
Back to top
Me Only
Guest





PostPosted: Thu Dec 07, 2006 7:07 pm    Post subject: Re: What is the Best Way to calculate hours differents? Reply with quote

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! Smile
Back to top
Alan Bellingham
Guest





PostPosted: Thu Dec 07, 2006 7:45 pm    Post subject: Re: What is the Best Way to calculate hours differents? Reply with quote

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





PostPosted: Thu Dec 07, 2006 7:53 pm    Post subject: Re: What is the Best Way to calculate hours differents? Reply with quote

"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 Smile

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





PostPosted: Thu Dec 07, 2006 10:30 pm    Post subject: Re: What is the Best Way to calculate hours differents? Reply with quote

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





PostPosted: Sat Dec 09, 2006 8:33 am    Post subject: Re: What is the Best Way to calculate hours differents? Reply with quote

Thomas Maeder [TeamB] wrote:

Quote:
Not to forget Newfoundland.
http://www.timetemperature.com/tzca/newfoundland_time_zone.shtml

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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Language C++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.