CodeCogs - An iteractive open source Numerical library Welcome... Login
CodeCogs
shopping cart
OSXWindowsLinux
Search CodeCogs
Numerical Components

Valid RSS

UnitsTime

world Time Diff

Available under GPL (Free) and Commercial licence
get a GPL licence
COST (GBP)
this unit 1.17
sub units 1.17
add a commercial licence to your cart
0
viewed 3750 times and licensed 15 times

Returns the time offset between two world locations

Further Info Controller: CodeCogs  Contact Controller
+View version details
Contents hide toc
buy now     get GPL     add to cart

Interface

#include <codecogs/units/time/worldtimediff.h>

using namespace Units::Time;

double worldTimeDiff (worldTimeZone LocA, worldTimeZone LocB)[inline]
Returns the time offset between two world locations

Function Documentation

 
doubleworldTimeDiffworldTimeZoneLocA
worldTimeZoneLocB )[inline]
Returns the difference in time between two location around the world, as a fraction of a day. The enumerated worldTimeZone locations contain the difference (in hours * 10) between Greenwich Mean Time (GMT) and the stated location. Therefore these enumerated values can be used explicitly to give the difference in time between two locations, for example: The difference in time between Moscow and New York is:
(wt_US_Canada_EasternTime - wt_Moscow)/10.0

Once you add in the addition factor of 1/24 to produce the fractional part of a day, the code for this module simply becomes:
inline double worldTimeDiff(worldTimeZone LocA, worldTimeZone LocB)
{
  return (LocA - LocB)/(24 * 10.0);     // to get fractions of a day
}
Therefore in most instances you may prefer to do this calculations directly.

Examples:

This example gives you the standard times in NewYork, Paris and London. It assumes the computer is based in London.
#include <stdio.h>
#include <codecogs/units/time/now.h>
#include <codecogs/units/time/worldtimediff.h>
#include <codecogs/units/time/timehms.h>
 
using namespace Units::Time;
 
void main()
{
double london=now(st_None);
double ny=london + worldTimeDiff(wt_US_Canada_EasternTime, wt_London);
double paris=london + worldTimeDiff(wt_Paris, wt_London);
 
int h,m,s;
timeHMS(london, h,m,s);
printf("\n Standard time in London is:   %02d:%02d:%02d", h,m,s);
timeHMS(ny, h,m,s);
printf("\n Standard time in New York is: %02d:%02d:%02d", h,m,s);
timeHMS(paris, h,m,s);
printf("\n Standard time in Paris is:    %02d:%02d:%02d", h,m,s);
}
A simple extension, using summerTime, ensures that summer time is applied (as appropriate), i.e
timeHMS(london + summerTime(london, st_UK)/24.0, h,m,s);
printf("\n The time in London is:   %02d:%02d:%02d", h,m,s);
timeHMS(ny + summerTime(london, st_USA)/24.0, h,m,s);
printf("\n The time in New York is: %02d:%02d:%02d", h,m,s);
timeHMS(paris + summerTime(london, st_EU)/24.0, h,m,s);
printf("\n The time in Paris is:    %02d:%02d:%02d", h,m,s);
Parameters:
LocAfirst time zone
LocBsecond time zone
Returns:
the fraction of a 24hr between the two locations
Authors:
Will Bateman (Nov 2004)
Source Code:

To view or download source code you need either a GPL or Commercial Licence.

buy now     get GPL     add to cart

Not a member, then Register with CodeCogs. Already a Member, then Login.


Page Comments

Format Excel Equations

  You must login to leave a messge


Last Modified: 18 Oct 07 @ 17:07     Page Rendered: 2010-03-14 10:39:36

Valid CSS!   Valid XHTML 1.0 Transitional