1

I tried this code in linux machines,

my $sysdate = strftime "%Y%m%d%T", (localtime);    
my $daylight_saving_time = strftime '%z', (localtime);

i get below output,

sysdate = 2013051402:12:02    
daylight_saving_time = -0400

I tried same in solaries machines, i got this

sysdate = 2013051402:12:02
daylight_saving_time = %z

Anyone know the change to be done to get the daylight saving in solaries machines.

Thanks in Advance.

CloudyMarble
  • 36,908
  • 70
  • 97
  • 130
user2380503
  • 21
  • 2
  • 3

2 Answers2

1

The issue is that POSIX::strftime just calls your system's strftime(3), so you get whatever that is - or - is not. %z is not part of the POSIX.1 standard and is not consistent across systems. On other older versions of OSes, like HPUX, %z, is the same as %Z (time zone name). This is only for older versions.

On Solaris 8, 9 strftime does not support %z - with Solaris 10 it does.

This holds on more moderns versions Solaris 10 & Solaris 11:

%z Replaced by offset from UTC in ISO 8601:2000 standard format (+hhmm or -hhmm), or by no characters if no time zone is deter- minable. For example, "-0430" means 4 hours 30 minutes behind UTC (west of Greenwich). If tm_isdst is zero, the standard time off- set is used. If tm_isdst is greater than zero, the daylight sav- ings time offset if used. If tm_isdst is negative, no characters are returned.

So, this a C library function issue, perl sits on top of those libraries. I do not have a workaround.

jim mcnamara
  • 16,005
  • 2
  • 34
  • 51
0

Maybe the Date::Manip::TZ works on Solaris:

   use Date::Manip::TZ;
   my $tz = new Date::Manip::TZ;
   say "tz: $tz";
user1126070
  • 5,059
  • 1
  • 16
  • 15