Oliver Thieke wrote: > Hi out there, > > I'm having issues with retrieving the correct > time on my machine. In Germany it's now DST -
Kinda early for DST isn't it ? Does your computer think it's DST or not (you would think so from your next stmt) ? > the windows shell shows correctly > > C:\>TIME /T > 15:18 What's in the TZ env vrbl if anything ? > But no way to retrieve the correct time > with PERL: > > C:\>perl -e "my $time = localtime; print $time;" > Thu Mar 30 14:18:41 2006 > > C:\>perl -e "my $time = gmtime; print $time;" > Thu Mar 30 13:18:47 2006 > > C:\>perl -e "use ActiveState::DateTime qw(gmt_offset); print gmt_offset();" > 0100 > > C:\>perl -e "print( (localtime())[8] );" > 0 > > According to 'perlfunc': "$isdst is true if the specified > time occurs during Daylight Saving Time, false otherwise." > So - according to my understanding - "(localtime())[8]" > should have retured "1". What do you get when you run this: use strict; use warnings; use Time::Local; for (1 .. 3) { my $b = timelocal 1, 2, 3, $_, 4-1, 2006; my @b = localtime $b; $b = scalar localtime $b; print "@b - $b\n"; } __END__ I get: 1 2 3 1 3 106 6 90 0 - Sat Apr 1 03:02:01 2006 1 2 3 2 3 106 0 91 1 - Sun Apr 2 03:02:01 2006 1 2 3 3 3 106 1 92 1 - Mon Apr 3 03:02:01 2006 > I googled the web, searched CPAN and browsed thru > ActiveState docu - no real solution found so far. > The module "Win32::UTCFileTime" seems to be aware of > this problem but it deals with File times and I need > the system time. > > The only 2 solutions I figured out so far: > > 1.) $time = `TIME /T`; chomp( $time); > 2.) get time with "TIME /T", compare it with localtime, > calculate offset, use offset for further time processing > > Solution #1 has a perfomance penalty (lots of external command calls) > and #2 doesn't look very elegant... You could just use the difference between gmtime and localtime instead of shelling out. What are the settings for your clock in the toolbar ? If you right click on the clock and check what's on the Time Zone tab you should have your current time zone and there's a checkbox for automatic clock adjustment for DST. See if that's set properly. _______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs