2

I have a question about the TZ environment variable. I have the timezone configuration string as

CST+6CDT,M3.2.0/02:00:00,M11.1.0/02:00:00.

From the TZ string, I need to get the number of days for M3.2.0 and M11.1.0 for the current year. Also I need to calculate the starting and ending of daylight savings in UTC secs (starting from 00:00:00 on January 1, 1970).

I can get the current year using time function.

Code in C language. Any ideas please?

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
novice
  • 33
  • 4
  • @dirkgently: No; this question is wholly unrelated to the 'Leap year obstacle' question. That is asking about days between to calendar dates. This is asking about the inner workings of TZ environment variable. – Jonathan Leffler Jun 11 '12 at 19:14
  • @JonathanLeffler: Ah, alright. – dirkgently Jun 11 '12 at 19:15

1 Answers1

0

It ain't easy, and there is precious little standard C code (let alone Standard C code) to help. One possible source of parts of a solution is the Olson Time Zone Database at IANA. There is the time zone data itself, but there is also a code package that handles the time zone information. This includes surrogate standard C library functions, and also some extension library code. The code does handle the TZ variable; therefore, it has code that can help you. Whether that code is easily accessible is another matter. Determining time zone transitions (standard to daylight saving time, or winter to summer time), is also tricky. There's code that does that, but finding it may be tricky.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278