Thanks Zefram. That was exactly what I needed.

K Murphy

On Fri, 2007-03-30 at 05:22 +0100, Zefram wrote:
> crap wrote:
> >For the life of me I cannot figure this out. I am trying to look up the
> >timezone based off an hour offset. Is there a way to do this with
> >DateTime::TimeZone?
> 
> If you want a timezone that is just a fixed hour offset, then just do
> 
>       $tz = DateTime::TimeZone->new->new(name => "-0400");
> 
> That's a timezone that's permanently four hours behind UT.
> 
> But I suspect that what you actually want is to put in "-0400" and get
> back one of the civil timezones, with DST rules, that happens to be at
> UT-4h currently.  There are several of these, such as America/New_York
> and America/Cuiaba, so at best you'd expect to get a list of matching
> timezones.  The timezones aren't indexed in this way, so you'd have to
> iterate through the lot checking each.  DateTime::TimeZone->all_names
> provides the list that you'll need to check through.
> 
> -zefram
> 

Reply via email to