3

In a question about getting a system's time zone, this answer did not get up-voted.

It suggests the use of tzset() and some system globals (e.g. daylight, timezone, and tzname) from time.h.

After some testing, I was able to get accurate results from this method on both Windows and Mac. But I'm guessing the answer mentioned above was not up-voted for a reason. Is this true? Should I prefer OS-specific calls instead of this C-standard?

Community
  • 1
  • 1
Elliot Cameron
  • 5,235
  • 2
  • 27
  • 34

1 Answers1

1

No, if there is not an standard C function (and you are programming to at least one POSIX compliant system) then you should use prefer POSIX functions over OS specific ones.

If one of your systems is not POSIX compliant, then you should have an OS specific solution only for that system.

Governa
  • 908
  • 10
  • 21
  • I think they didn't up vote your answer because the question was tagged c++/boost and tzset is an POSIX function. But it would be better to ask there ;) – Governa Jan 18 '12 at 19:47
  • 1
    Windows is not POSIX-compliant, yet it supports it. What's up with that? – Elliot Cameron Feb 03 '12 at 20:03