Skip Menu |

This queue is for tickets about the DateTime-TimeZone-Local-Win32 CPAN distribution.

Report information
The Basics
Id: 100334
Status: resolved
Priority: 0/
Queue: DateTime-TimeZone-Local-Win32

People
Owner: DAPINK [...] cpan.org
Requestors: frioux [...] gmail.com
Cc: DAPINK [...] cpan.org
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 1.81



Subject: Detecting current timezone on 2003 with Perl 5.20 and higher is broken
Date: Fri, 14 Nov 2014 08:19:21 -0600
To: bug-DateTime-TimeZone [...] rt.cpan.org
From: fREW Schmidt <frioux [...] gmail.com>
This is not technically your bug, but your upstreams for this bug are... dormant at best. Basically, Win32API::Registry is broken for 5.20 and higher (https://rt.perl.org/Public/Bug/Display.html?id=123207) but is unlikely to be fixed (https://rt.cpan.org/Ticket/Display.html?id=37750.) I've reported the bug to Win32::TieRegistry (See https://rt.cpan.org/Ticket/Display.html?id=25102 https://rt.cpan.org/Ticket/Display.html?id=39818 https://rt.cpan.org/Ticket/Display.html?id=97127 https://rt.cpan.org/Ticket/Display.html?id=99892 ) I'm going to make a local patch for my codebase using Win32::Registry instead, as jdb seems to be willing to ensure that it stays functional. I will send you a patch when I have one. -- fREW Schmidt https://blog.afoolishmanifesto.com
Download (untitled)
application/pgp-signature 819b

Message body not shown because it is not plain text.

On Fri Nov 14 09:19:32 2014, frew wrote: Show quoted text
> This is not technically your bug, but your upstreams for this bug > are... dormant at best. Basically, Win32API::Registry is broken for > 5.20 and higher > (https://rt.perl.org/Public/Bug/Display.html?id=123207) but is > unlikely to be fixed > (https://rt.cpan.org/Ticket/Display.html?id=37750.) > > I've reported the bug to Win32::TieRegistry (See > https://rt.cpan.org/Ticket/Display.html?id=25102 > https://rt.cpan.org/Ticket/Display.html?id=39818 > https://rt.cpan.org/Ticket/Display.html?id=97127 > https://rt.cpan.org/Ticket/Display.html?id=99892 > ) > > I'm going to make a local patch for my codebase using Win32::Registry > instead, as jdb seems to be willing to ensure that it stays > functional. I will send you a patch when I have one. >
Ok, I wrote a patch to fix this for real, see attached. Tested against 2008 and 2003.
Subject: dt.patch
--- a/perl/vendor/lib/DateTime/TimeZone/Local/Win32.pm +++ b/perl/vendor/lib/DateTime/TimeZone/Local/Win32.pm @@ -5,7 +5,7 @@ use warnings; use parent 'DateTime::TimeZone::Local'; -use Win32::TieRegistry ( 'KEY_READ', Delimiter => q{/} ); +use Win32::Registry; sub Methods { return qw( FromEnv FromRegistry ) } @@ -222,31 +222,46 @@ sub EnvVars { return 'TZ' } sub _FindWindowsTZName { my $class = shift; - my $LMachine = $Registry->Open( 'LMachine/', { Access => KEY_READ } ); - - my $TimeZoneInfo = $LMachine->{ - 'SYSTEM/CurrentControlSet/Control/TimeZoneInformation/'}; + my $tz; + $::HKEY_LOCAL_MACHINE->Open( + 'SYSTEM\CurrentControlSet\Control\TimeZoneInformation', + $tz + ) or die "$^E"; + my %tz_values; + $tz->GetValues(\%tz_values) or die "$^E"; + my $value = $tz_values{TimeZoneKeyName}[2]; # Windows Vista, Windows 2008 Server - if ( defined $TimeZoneInfo->{'/TimeZoneKeyName'} - && $TimeZoneInfo->{'/TimeZoneKeyName'} ne '' ) { - return $TimeZoneInfo->{'/TimeZoneKeyName'}; + if ( defined $value && $value ne '') { + return $value } else { - my $AllTimeZones = $LMachine->{ - 'SOFTWARE/Microsoft/Windows NT/CurrentVersion/Time Zones/'} - - # Windows NT, Windows 2000, Windows XP, Windows 2003 Server - ? $LMachine->{ - 'SOFTWARE/Microsoft/Windows NT/CurrentVersion/Time Zones/'} + my $std_name = $tz_values{StandardName}[2]; + my $all_tzs; + # Windows NT, Windows 2000, Windows XP, Windows 2003 Server + $::HKEY_LOCAL_MACHINE->Open( + 'SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones', + $all_tzs + ) or die "$^E"; + my @keys; + $all_tzs->GetKeys(\@keys) or die "$^E"; + + # Windows 95, Windows 98, Windows Millenium Edition + if (!@keys) { + $::HKEY_LOCAL_MACHINE->Open( + 'SOFTWARE\Microsoft\Windows\CurrentVersion\Time Zones', + $all_tzs + ) or die "$^E"; + $all_tzs->GetKeys(\@keys) or die "$^E"; + } - # Windows 95, Windows 98, Windows Millenium Edition - : $LMachine->{ - 'SOFTWARE/Microsoft/Windows/CurrentVersion/Time Zones/'}; + foreach my $zone ( @keys ) { + my $cur_tz; + $all_tzs->Open($zone, $cur_tz) or die "$^E"; + my %values; + $cur_tz->GetValues(\%values) or die "$^E"; - foreach my $zone ( $AllTimeZones->SubKeyNames() ) { - if ( $AllTimeZones->{ $zone . '/Std' } eq - $TimeZoneInfo->{'/StandardName'} ) { + if ( $values{Std}[2] eq $std_name ) { return $zone; } }
David Pinkowitz has been working on Win32 support. I've added him as a CC on this ticket, and I'll let him review any patches. He's planning on releasing a DT::TZ::Local::Win32 as a separate distro soon.