I have forgotten

• https://me.yahoo.com
COST (GBP)
1.40
0.50
0

# world Time Diff

Returns the time offset between two world locations
Controller: CodeCogs

C++

## WorldTimeDiff

 doubleworldTimeDiff( worldTimeZone LocA worldTimeZone LocB )[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 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

 LocA first time zone LocB second time zone

### Returns

the fraction of a 24hr between the two locations

### Authors

Will Bateman (Nov 2004)
##### Source Code

Source code is available when you agree to a GP Licence or buy a Commercial Licence.

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