Matt Sergeant wrote:
> 
> On Mon, 16 Oct 2000, David E. Wheeler wrote:
> 
> I'm confused. Why are you using gmtime then?

Because if no time is supplied, I want it to default to GMT. I'm setting
up an app in which the database will store date/time in GMT only, but
will serve it out to users in their own local timezones. So sometimes
it'll be GMT and sometimes it won't.

> > Does it know Time Zones?
> 
> It just does strftime, so you can do what you've got below without loading
> POSIX. Plus its OO so it makes more sense (IMHO).

So %Z still won't work properly when I use gmtime.
 

> I'm not sure I understand the correctness of this. Shouldn't it be:
> 
> gmtime($_[0] || time)
> 
> or
> 
> localtime($_[0] || time)
> 

No, because if no time is supplied, I want UTC. If a time is supplied, I
want no alteration to that time (gmtime would correct it). The goal is
to get it to act exactly as ht_time does. Maybe this:

BEGIN {
    if ($ENV{MOD_PERL}) {
        use Apache::Util;
        $format_date = \&Apache::Util::ht_time;
    } else {
        use POSIX;
        $format_date = sub {
            POSIX::strftime($_[1] || $_[0] ? "%a, %d %b %Y %T %Z" :
                            "%a, %d %b %Y %T GMT", $_[0] ? localtime($_[0]) :
                            (gmtime)[0..7]);
        };
    }
}

Which also corrects for the one hour difference between them (why would
gmtime() ever return true for daylight savings??? It does!

D

-- 
David E. Wheeler
Software Engineer
Salon Internet                                     ICQ:   15726394
[EMAIL PROTECTED]                                       AIM:   dwTheory

Reply via email to