[27273] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 9031 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 8 18:05:43 2006

Date: Wed, 8 Mar 2006 15:05:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 8 Mar 2006     Volume: 10 Number: 9031

Today's topics:
        ANNOUNCE: DBIx::Admin::BackupRestore V 1.09 <ron@savage.net.au>
        Year of day in localtime and timelocal don't match? (J Moreno)
    Re: Year of day in localtime and timelocal don't match? <no@email.com>
    Re: Year of day in localtime and timelocal don't match? <noreply@gunnar.cc>
    Re: Year of day in localtime and timelocal don't match? <no@email.com>
    Re: Year of day in localtime and timelocal don't match? <christoph.lamprecht.no.spam@web.de>
    Re: Year of day in localtime and timelocal don't match? <1usa@llenroc.ude.invalid>
    Re: Year of day in localtime and timelocal don't match? lawrence@hummer.not-here.net
    Re: Year of day in localtime and timelocal don't match? <noreply@gunnar.cc>
    Re: Year of day in localtime and timelocal don't match? <noreply@gunnar.cc>
    Re: Year of day in localtime and timelocal don't match? <no@email.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Mon, 6 Mar 2006 04:22:30 GMT
From: Ron Savage <ron@savage.net.au>
Subject: ANNOUNCE: DBIx::Admin::BackupRestore V 1.09
Message-Id: <Ivtows.1sDw@zorch.sf-bay.org>

The pure Perl module DBIx::Admin::BackupRestore V 1.09
is available immediately from CPAN,
and from http://savage.net.au/Perl-modules.html.

On-line docs, and a *.ppd for ActivePerl are also
available from the latter site.

An extract from the docs:

1.09  Thu Feb 09 15:53:00 2006
	- Fix broken method restore_in_order()
	- Add support for exporting from Oracle by adding 4 new parameters to new():
		o dbi_catalog
		o dbi_schema
		o dbi_table
		o dbi_type
		These are actually used in the call to DBI's table_info() method.
		Usage:
		o MySQL: The default values of these parameters Just Work
		o Oracle: Set dbi_schema to the uc(username) used when you called DBI's
connect() method
		o Postgres: Set dbi_schema to 'public'
	- Importing into Oracle does not handle sequences at all
	- Switch from DBI's table() method to table_info(). This is for Oracle
	- Discard table names which match /^BIN\$.+\$./. This is for Oracle
	- Change the handling of quotes around schema and table names. Previously the
first and last quote was removed, so a name like `public.t` became public.t. But
with Oracle, quotes are used around the schema and table names separately, so
"X"."T" became X"."T :-(.
		Now, all quotes are removed, so `public.t` still becomes public.t, but also
"X"."T" becomes X.T.




------------------------------

Date: Wed, 8 Mar 2006 16:53:22 -0500
From: planB@newsreaders.com (J Moreno)
Subject: Year of day in localtime and timelocal don't match?
Message-Id: <1hbw3qt.mwmbb31c2hn32N%planB@newsreaders.com>

As I read the documentation, the day of the year in both should be the
same, but when I run the script below, they differ by a day (I get the
day before the today's day as returned by localtime).

Is this a problem with the documentation, my reading of the
documentation, or a bug (i.e. do I have to check to see if the behavior
changes based upon version or something)?

###
use warnings;
use strict;

use Time::Local 'timelocal_nocheck';

$\ = "\n";

my $b;
my $day_of_year;

($b,$b,$b,$b,$b,$b,$b,$day_of_year) = localtime;

print "From localtime: " . $day_of_year;

($b,$b,$b,$b,$b,$b,$b,$day_of_year) = localtime timelocal_nocheck
(0,0,0,$day_of_year, 0, 0);

print "From localtime via timelocal_nocheck: " . $day_of_year;

###

Outputs:

From localtime: 66
From localtime via timelocal_nocheck 65



-- 
John Moreno
"Everything is futile." -- Marvin of Borg


------------------------------

Date: Wed, 08 Mar 2006 22:04:57 +0000
From: Brian Wakem <no@email.com>
Subject: Re: Year of day in localtime and timelocal don't match?
Message-Id: <4792o9FeblerU1@individual.net>

J Moreno wrote:

> As I read the documentation, the day of the year in both should be the
> same, but when I run the script below, they differ by a day (I get the
> day before the today's day as returned by localtime).
> 
> Is this a problem with the documentation, my reading of the
> documentation, or a bug (i.e. do I have to check to see if the behavior
> changes based upon version or something)?
> 
> ###
> use warnings;
> use strict;
> 
> use Time::Local 'timelocal_nocheck';
> 
> $\ = "\n";
> 
> my $b;
> my $day_of_year;
> 
> ($b,$b,$b,$b,$b,$b,$b,$day_of_year) = localtime;
> 
> print "From localtime: " . $day_of_year;
> 
> ($b,$b,$b,$b,$b,$b,$b,$day_of_year) = localtime timelocal_nocheck
> (0,0,0,$day_of_year, 0, 0);

                          ^^ year 0 is equivalent to 2000


> print "From localtime via timelocal_nocheck: " . $day_of_year;
> 
> ###
> 
> Outputs:
> 
> From localtime: 66
> From localtime via timelocal_nocheck 65


2000 was a leap year.


-- 
Brian Wakem
Email: http://homepage.ntlworld.com/b.wakem/myemail.png


------------------------------

Date: Wed, 08 Mar 2006 23:09:03 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Year of day in localtime and timelocal don't match?
Message-Id: <47933sFei6prU1@individual.net>

Brian Wakem wrote:
> J Moreno wrote:
>>
>>($b,$b,$b,$b,$b,$b,$b,$day_of_year) = localtime timelocal_nocheck
>>(0,0,0,$day_of_year, 0, 0);
> 
>                           ^^ year 0 is equivalent to 2000

True.

> 2000 was a leap year.

Not true.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


------------------------------

Date: Wed, 08 Mar 2006 22:14:50 +0000
From: Brian Wakem <no@email.com>
Subject: Re: Year of day in localtime and timelocal don't match?
Message-Id: <4793aqFeblerU3@individual.net>

Gunnar Hjalmarsson wrote:

> Brian Wakem wrote:
>> J Moreno wrote:
>>>
>>>($b,$b,$b,$b,$b,$b,$b,$day_of_year) = localtime timelocal_nocheck
>>>(0,0,0,$day_of_year, 0, 0);
>> 
>>                           ^^ year 0 is equivalent to 2000
> 
> True.
> 
>> 2000 was a leap year.
> 
> Not true.
> 


According to the Gregorian calendar, which is the civil calendar in use
today, years evenly divisible by 4 are leap years, with the exception of
centurial years that are not evenly divisible by 400. Therefore, the years
1700, 1800, 1900 and 2100 are not leap years, but 1600, 2000, and 2400 are
leap years.



-- 
Brian Wakem
Email: http://homepage.ntlworld.com/b.wakem/myemail.png


------------------------------

Date: Wed, 08 Mar 2006 23:16:31 +0100
From: Ch Lamprecht <christoph.lamprecht.no.spam@web.de>
Subject: Re: Year of day in localtime and timelocal don't match?
Message-Id: <dunl3u$2gi$2@online.de>

Brian Wakem wrote:
> J Moreno wrote:
> 
> 
>>As I read the documentation, the day of the year in both should be the
>>same, but when I run the script below, they differ by a day (I get the
>>day before the today's day as returned by localtime).

>>###
>>use warnings;
>>use strict;
>>
>>use Time::Local 'timelocal_nocheck';
>>
>>$\ = "\n";
>>
>>my $b;
>>my $day_of_year;
>>
>>($b,$b,$b,$b,$b,$b,$b,$day_of_year) = localtime;
>>
>>print "From localtime: " . $day_of_year;
>>
>>($b,$b,$b,$b,$b,$b,$b,$day_of_year) = localtime timelocal_nocheck
>>(0,0,0,$day_of_year, 0, 0);

> 
>>print "From localtime via timelocal_nocheck: " . $day_of_year;
>>

> 
> 2000 was a leap year.
> 
Hi,
did you check with 2001 ??

timelocal_nocheck expects a day_of_month as 4th param ranging from 1 to 
something .
Localtime returns day_of_year ranging from 0 to 364.

Christoph


-- 

perl -e "print scalar reverse q/ed.enilno@ergn.l.hc/"


------------------------------

Date: Wed, 08 Mar 2006 22:17:53 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Year of day in localtime and timelocal don't match?
Message-Id: <Xns9780B012CE30Casu1cornelledu@127.0.0.1>

planB@newsreaders.com (J Moreno) wrote in news:1hbw3qt.mwmbb31c2hn32N%
planB@newsreaders.com:

> As I read the documentation, the day of the year in both should be the
> same, but when I run the script below, they differ by a day (I get the
> day before the today's day as returned by localtime).
> 
> Is this a problem with the documentation, my reading of the
> documentation, or a bug (i.e. do I have to check to see if the
> behavior changes based upon version or something)?
> 
 ...

> ($b,$b,$b,$b,$b,$b,$b,$day_of_year) = localtime timelocal_nocheck
> (0,0,0,$day_of_year, 0, 0);

        $time = timelocal($sec,$min,$hour,$mday,$mon,$year);

You are passing to this function:

$sec = 0
$min = 0
$hour = 0
$mday = $day_of_year
$mon = 0 
$year = 0 

$day_of_year is out of range for $mday. While the docs show examples of 
such usage, it also warns:

 Your mileage may vary when trying these with minutes and hours, and it
 doesn't work at all for months.

I guess this falls under "your mileage may vary".


D:\Home\asu1\UseNet\clpmisc> cat time.pl
use warnings;
use strict;

use Time::Local 'timelocal';

my $d1 = (localtime)[7];

print "From localtime: $d1\n";

my $d2 = (localtime timelocal(localtime))[7];

print "From localtime via timelocal: $d2\n";


D:\Home\asu1\UseNet\clpmisc> time.pl
From localtime: 66
From localtime via timelocal: 66

-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html



------------------------------

Date: 08 Mar 2006 14:19:22 -0800
From: lawrence@hummer.not-here.net
Subject: Re: Year of day in localtime and timelocal don't match?
Message-Id: <873bhszij9.fsf@hummer.i-did-not-set--mail-host-address--so-shoot-me>

Gunnar Hjalmarsson <noreply@gunnar.cc> writes:
> > 2000 was a leap year.
> 
> Not true.
> 

It wasn't?  Shit -- what was it I was doing all day on 29 Feb 2000
then?  According to unix cal and emacs ccalendar-mode there was, so I
must not be hallucinating.

         January 2000            February 2000              March 2000
     Su Mo Tu We Th Fr Sa     Su Mo Tu We Th Fr Sa     Su Mo Tu We Th Fr Sa
                        1            1  2  3  4  5               1  2  3  4
      2  3  4  5  6  7  8      6  7  8  9 10 11 12      5  6  7  8  9 10 11
      9 10 11 12 13 14 15     13 14 15 16 17 18 19     12 13 14 15 16 17 18
     16 17 18 19 20 21 22     20 21 22 23 24 25 26     19 20 21 22 23 24 25
     23 24 25 26 27 28 29     27 28 29                 26 27 28 29 30 31


-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
	Lawrence Statton - lawrenabae@abaluon.abaom s/aba/c/g
Computer  software  consists of  only  two  components: ones  and
zeros, in roughly equal proportions.   All that is required is to
sort them into the correct order.


------------------------------

Date: Wed, 08 Mar 2006 23:26:41 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Year of day in localtime and timelocal don't match?
Message-Id: <47944uFeiiheU1@individual.net>

J Moreno wrote:
> As I read the documentation, the day of the year in both should be the
> same, but when I run the script below, they differ by a day (I get the
> day before the today's day as returned by localtime).
> 
> Is this a problem with the documentation, my reading of the
> documentation, or a bug (i.e. do I have to check to see if the behavior
> changes based upon version or something)?

<snip>

> ($b,$b,$b,$b,$b,$b,$b,$day_of_year) = localtime;
> 
> print "From localtime: " . $day_of_year;

 From "perldoc -f localtime":
"$yday is the day of the year, in the range 0..364 (or 0..365 in leap 
years.)"

Hence you need to pass $day_of_year+1 to timelocal_nocheck() to make the 
8:th element returned by localtime() equal $day_of_year.

     $day_of_year =
       (localtime timelocal_nocheck 0,0,0,$day_of_year+1,0,0)[7];
-----------------------------------------------------^^

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


------------------------------

Date: Wed, 08 Mar 2006 23:32:28 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Year of day in localtime and timelocal don't match?
Message-Id: <4794fpFei4puU1@individual.net>

Brian Wakem wrote:
> Gunnar Hjalmarsson wrote:
>>Brian Wakem wrote:
>>>2000 was a leap year.
>>
>>Not true.
>
> According to the Gregorian calendar, which is the civil calendar in use
> today, years evenly divisible by 4 are leap years, with the exception of
> centurial years that are not evenly divisible by 400. Therefore, the years
> 1700, 1800, 1900 and 2100 are not leap years, but 1600, 2000, and 2400 are
> leap years.

I was wrong; sorry.

Nevertheless, that fact is unrelated to the OP's observation. See my 
other post in this thread.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


------------------------------

Date: Wed, 08 Mar 2006 22:47:33 +0000
From: Brian Wakem <no@email.com>
Subject: Re: Year of day in localtime and timelocal don't match?
Message-Id: <479585FehgriU1@individual.net>

Gunnar Hjalmarsson wrote:

> Brian Wakem wrote:
>> Gunnar Hjalmarsson wrote:
>>>Brian Wakem wrote:
>>>>2000 was a leap year.
>>>
>>>Not true.
>>
>> According to the Gregorian calendar, which is the civil calendar in use
>> today, years evenly divisible by 4 are leap years, with the exception of
>> centurial years that are not evenly divisible by 400. Therefore, the
>> years 1700, 1800, 1900 and 2100 are not leap years, but 1600, 2000, and
>> 2400 are leap years.
> 
> I was wrong; sorry.
> 
> Nevertheless, that fact is unrelated to the OP's observation. See my
> other post in this thread.


No need to apologise. 

I saw it was 1 day out, noticed the leap year and assumed that was the
answer, so I was wrong too.


-- 
Brian Wakem
Email: http://homepage.ntlworld.com/b.wakem/myemail.png


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 9031
***************************************


home help back first fref pref prev next nref lref last post