On Sun, Dec 08, 2002 at 11:54:11PM +0000, Paul Makepeace wrote: > FWIW, intuition tells me, if I were doing this, to look at tzset(3).
#!/usr/bin/perl -w use strict; use Inline C => <<'EOC'; #include <time.h> #include <stdlib.h> #include <stdio.h> int tz_offset(char *tz) { extern long timezone; long offset; char *current_tz = getenv("TZ"); if (setenv("TZ", tz, 1 /* overwrite */) != 0) { fprintf(stderr, "Couldn't set TZ to %s\n", tz); return 0; } tzset(); offset = timezone; if(current_tz) { if (setenv("TZ", current_tz, 1 /* overwrite */) != 0) { fprintf(stderr, "Couldn't set TZ back to %s\n", current_tz); return 0; } tzset(); } return offset; } EOC print "$_: ", tz_offset($_), "\n" for @ARGV ? @ARGV : qw(Asia/Dacca Europe/Bratislava CET Factory); __END__ gives: Asia/Dacca: -21600 Europe/Bratislava: -3600 CET: -3600 Factory: 0 Heh. Paul (no longer an Inline::C virgin) -- Paul Makepeace ....................................... http://paulm.com/ "If dinosaurs are extinct, then we will go to the zoo." -- http://paulm.com/toys/surrealism/