Btw, as should be obvious from the last couple of emails, I spent the
evening plaing with DateTime, and I've very impressed.  Thought I should
mention that as I send in a slew of bug reports.

Currently epoch() on DateTime.pm calculates the epoch incorrectly, it
assumes that all objects are stored as GMT, rather then as localtime with
an offset.

One solution to this problem is to clone() the DateTime object, and cast
it to UTC before passing it to Time::Local::timegm()

I've attached a patch that does this.

As I mentioned in my last email, I've just started exploring DateTime so
there might be a more elegant solution I'm not seeing.

kellan

-- 
"the truth is always revolutionary" [antonio gramsci]

[EMAIL PROTECTED]
diff -Naur DateTime/DateTime.pm DateTime_epoch_tz/DateTime.pm
--- DateTime/DateTime.pm        2003-02-13 06:47:23.000000000 +0000
+++ DateTime_epoch_tz/DateTime.pm       2003-02-13 06:47:56.000000000 +0000
@@ -611,6 +611,9 @@
 sub epoch {
     my $self = shift;
 
+       my $dt = $self->clone();
+       $dt->set_time_zone('UTC');
+       
     # timegm may die if given components outside of the ranges it
     # can handle.  In that case return undef.
     return

Reply via email to