strftime '%z', (localtime) is not working as expected in solaris machines

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.

Answers


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.


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

   use Date::Manip::TZ;
   my $tz = new Date::Manip::TZ;
   say "tz: $tz";

Need Your Help

Failed password verification in own login class

php login

i am currently working on my own user class with login and register functions. I am doing this mainly for the learing experience. Now i am having a problem wich i am unable to resolve.

Should Git be used to store continuous integration builds?

git build continuous-integration ivy artifactory

In an environment where multiple builds (release candidate packages) can be created daily but only one a month gets promoted to production, I think storing every build in Git would be wasteful but ...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.