5
$\begingroup$

I'd like to configure some of my notebooks to assume all calculations using dates, times and locations (notably AstronomicalData , but others too) take place at the Greenwich Observatory.

I know I can achieve this by unprotecting $TimeZone and setting it to 0, as with

    $GeoLocation = {51.476786, 0.00000000};
    Unprotect[$TimeZone];
    $TimeZone = 0;
    Protect[$TimeZone];

but worry that this might have some other consequences that would confuse date and time functions.

Is it safe to do this? Does changing the value of $TimeZone have side effects I should avoid?

$\endgroup$
  • $\begingroup$ Can't you put it in a Block? In any case, I don't see any side effects, other than some date conversions and W|A calls getting messed up. $\endgroup$ – rm -rf Dec 4 '12 at 22:35
  • $\begingroup$ @rm-rf: Block, if you mean Block[{$TimeZone=0}, ...], wasn't working for me for some functions, at least not DateList]. Also, I'd prefer to make the change global, rather than have to remember to make the change each time I do something that depends on it. $\endgroup$ – orome Dec 4 '12 at 22:39
  • $\begingroup$ Why not use TimeZone? That's what is seems to be for. E.g. Table[DateString[TimeZone -> i], {i, 0, 6}] from the documentation. $\endgroup$ – DavidC Dec 4 '12 at 22:43
  • $\begingroup$ @DavidCarraher: All calculations, globally. Forgetting to do that just once could really mess things up, and that's what I'm trying to avoid. $\endgroup$ – orome Dec 4 '12 at 22:46
  • 1
    $\begingroup$ @rm-rf: Hmmm... Block may not work, simply because DateList looks broken. Try $TimeZone=0 and then DateList[...,TimeZone->0]. That should leave the date given unchanged, but (if you're machine timezone isn't 0) it won't. I may not even be able to do what I want with a global change of $TimeZone. $\endgroup$ – orome Dec 4 '12 at 22:59
4
$\begingroup$

As the Locale & Internalization guide page says $TimeZone is resettable.

Mathematica graphics

If the developers would foresee adverse effects I guess they wouldn't have documented it in this way. The only problem that I can see is that you have to take care that your system time is also set to GMT, otherwise real-time calculations (e.g., elevation of the sun as seen in Greenwich at the time of evaluation) will give the incorrect result.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.