Today in Cairo Apr 25 2008

2008-02-06 Thread Max Campos

Hi Folks,

It looks like Cairo changes its daylight savings at 11pm, causing  
truncate(to= day) to fail on Apr 25, 2008. Is this by chance  
corrected in a newer version of DateTime?  I'm using v.30


If not, then I guess this really opens up a can of worms as to what  
today should do on this date.


use DateTime;
$x = DateTime-new(year = 2008, month = 4, day = 25, hour = 12,  
minute = 12);

$x-set_time_zone('Africa/Cairo');
$x-truncate(to = 'day');
print $x\n;
-
Invalid local time for date in time zone: Africa/Cairo

- Max


Bug: DT::Event::Recurrence Modifies Params

2005-01-06 Thread Max Campos
I noticed a little bug today.  DateTime::Event::Recurrence modifies the 
parameters that are passed to it.

Unfortunately I don't have the time to dig through the code and fix it 
myself.

Is there a defect tracking system that I should log this into?
btw - Dave, Flavio, etc, thanks for all of your hard work.  In the 
project I'm working on it has saved countless hours!

Example:
use DateTime::Event::Recurrence;
use Data::Dumper;
my @days = qw(1 2 3 4 5);
print Dumper([EMAIL PROTECTED]);
DateTime::Event::Recurrence-weekly(days = [EMAIL PROTECTED]);
print Dumper([EMAIL PROTECTED]);
$VAR1 = [
  '1',
  '2',
  '3',
  '4',
  '5'
];
$VAR1 = [
  0,
  1,
  2,
  3,
  4
];


Re: How many days between 2 DTs?

2004-12-31 Thread Max Campos
Also, maybe DateTime should throw some kind of error when you run 
in_units and a higher partition is being stripped off?

Ex:
my $dur = DateTime::Duration-new(months = 3, days= 4);
$dur-in_units(days);  # Error; currently 4
$dur-in_units(years); # No error, 0.
It's not an error, and warnings for this sort of stuff will just annoy 
people.
I think this your average newcomer will find this very confusing!
# From the POD
my $dur = DateTime::Duration-new( years = 1, months = 15 );
$dur-in_units( years );# 2
$dur-in_units( months );   # 27
$dur-in_units('days');# 0
- or another one -
(DateTime-now - DateTime-today)-in_units('hours'); # 9   
How many hours between now and midnight?
(DateTime-now - DateTime-today)-in_units('minutes'); # 591  How 
many minutes between now and midnight?
(DateTime-now - DateTime-today)-in_units('seconds');# 34 How 
many seconds between now and midnight?

I think that a method like this should do what you expect it to do,  
and if it can't do that, then return an error.This is one of those 
cases where instead of returning an error, it returns an unexpected 
result.   Very few people new to DateTime would expect this behavior.  
Or if they planned for that sort of result, they would have called 
delta_*.

imho
DateTime does a great job of staying accurate during all sorts of 
calendrical calculations.  Sometimes, however, I feel like it makes 
really common tasks cumbersome in favor remaining calendrically 
correct.  This, IMHO, will probably keep DateTime from replacing the 
other modules  becoming the standard time module for perl.  That's a 
shame, because other than a few little nuances it's really an excellent 
(and very complete) set of modules.

Ex:
- DateTime-now returns UTC
- There's no way to set a default timezone
- DateTime::Duration should be the so called stopwatch duration
I'm sure there are others, but those are the ones that I run into most 
commonly.
/imho

Finally, I think some explanation should be added to  
DT:Duration::in_units that explains all of this!
I'll add it.  The conversion issues are explained in DateTime.pm at 
length and mentioned in the DESCRIPTION section of DT::Duration, but 
not in the in_units method.
Yeah, I remembered reading that somewhere - so just a pointer then 
would be fine.  thanks.

- Max

Re: How many days between 2 DTs?

2004-12-30 Thread Max Campos
Hi Dave,
	After feedback from another poster, it looks like the answer is the 
following:

$now-delta_days($dt)-in_units('days');
It looks like durations end up broken up into 4 partitions.  
Conversions can happen only within the partitions, not between:

years/months
weeks/days
hours/minutes
seconds/ns
Also, maybe DateTime should throw some kind of error when you run 
in_units and a higher partition is being stripped off?

Ex:
my $dur = DateTime::Duration-new(months = 3, days= 4);
$dur-in_units(days);  # Error; currently 4
$dur-in_units(years); # No error, 0.
Finally, I think some explanation should be added to  
DT:Duration::in_units that explains all of this!

- Max
Well, here we go again with DateTime::Duration.
Here's a simple problem - How many days are between two DateTime's ?  
Here is my attempt, but it fails.

Suggestions?
You want the delta_days() method.



How many days between 2 DTs?

2004-12-29 Thread Max Campos
Well, here we go again with DateTime::Duration.
Here's a simple problem - How many days are between two DateTime's ?  
Here is my attempt, but it fails.

Suggestions?
=
use DateTime;
my $tz = America/Los_Angeles;
my $dt = new DateTime(
year = 2004,
month = 9,
day = 25,
time_zone = $tz);
my $now = DateTime-now(time_zone = $tz);
my $today = $now-clone-truncate(to = 'day');
my $day = $dt-clone-truncate(to = 'day');
printf(Number of days: %s\n, ($day - $today)-in_units('days'));
=
[EMAIL PROTECTED] ~]$ perl foo.pl
Number of days: -4
[EMAIL PROTECTED] ~]$
=
- Max


Bug: Storable on Infinite Dates Broken

2004-07-28 Thread Max Campos
Just FYI -

Storable freeze seems to fail when running against a
DateTime::Infinite::Future/Past object.  I believe it's because
$self-{locale} is not being defined.

I don't have a patch, but I thought you may want to at least scribble this
one down in the bug tracker.

===
use DateTime::Infinite;
use Storable;

my $future = DateTime::Infinite::Future-new;
Storable::freeze($future);
===

Item #1 returned by STORABLE_freeze for DateTime::Infinite::Future is not
a reference at ../../lib/Storable.pm (autosplit into
../../lib/auto/Storable/_freeze.al) line 282, at foo line 5




localtime DateTime Objects

2004-07-01 Thread Max Campos
All I want is simple local time date time manipulation without having 
to deal with timezones.

However, as illustrated below, I'm getting some weird (GMT?) results.   
Is this correct behavior?  I'm using stock Red Hat 9 perl 5.8.0.

=
use DateTime;
print DATE:   . `date`;
print DTNOW:  . DateTime-now . \n;
print DTABS:  . new DateTime(month = 7, day = 1, year = 2004, hour 
= 14) . \n;

=
Output:
DATE:  Thu Jul  1 14:05:03 PDT 2004
DTNOW: 2004-07-01T21:05:03
DTABS: 2004-07-01T14:00:00
- Max