Re: [Zope] Re: DateTime mess

2005-11-22 Thread Chris McDonough


On Nov 22, 2005, at 11:27 AM, Gabriel Genellina wrote:


At Tuesday 22/11/2005 05:50, Jürgen Herrmann wrote:


one more question (to the public!):
do we REALLY need dates <1900 / >2036 ? using unix timestamps for
storage and as the base for all conversions would make things a lot
easier!


Sure. What about birthdays of aged people? Long running forecasts?


The first time I read this, I thought it said "long-running people",  
which would be funnier. ;-)


___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Re: DateTime mess

2005-11-22 Thread Gabriel Genellina

At Tuesday 22/11/2005 05:50, Jürgen Herrmann wrote:


one more question (to the public!):
do we REALLY need dates <1900 / >2036 ? using unix timestamps for
storage and as the base for all conversions would make things a lot
easier!


Sure. What about birthdays of aged people? Long running forecasts?


Gabriel Genellina
Softlab SRL 


___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Re: DateTime mess

2005-11-22 Thread Jürgen Herrmann

[ Lennart Regebro wrote:]
> On 11/22/05, Jürgen Herrmann <[EMAIL PROTECTED]> wrote:
>> i'll surely change the storage format, when rewriting it!
>
> So you plan on having some version marker, or so, which
> tells which storage format is used?
>
> //Curious.

basicall i thought about having a dateime instance as "storage" in the
new implementation and test for it's existance on DateTime instances.

something like that:

dt = getattr(self, '_datetime', None)
if dt is not None:
  #new, everything ok
else:
  #migrate!

rfc!

regards, juergen herrmann
___

>> XLhost.de - eXperts in Linux hosting <<

Jürgen Herrmann
Bruderwöhrdstraße 15b, DE-93051 Regensburg

Fon:  +49 (0)700 XLHOSTDE [0700 95467833]
Fax:  +49 (0)721 151 463027
WEB:  http://www.XLhost.de
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Re: DateTime mess

2005-11-22 Thread Lennart Regebro
On 11/22/05, Jürgen Herrmann <[EMAIL PROTECTED]> wrote:
> i'll surely change the storage format, when rewriting it!

So you plan on having some version marker, or so, which
tells which storage format is used?

//Curious.

--
Lennart Regebro, Nuxeo http://www.nuxeo.com/
CPS Content Management http://www.cps-project.org/
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists -
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Re: DateTime mess

2005-11-22 Thread Jürgen Herrmann

[ Lennart Regebro wrote:]
> On 11/22/05, Jürgen Herrmann <[EMAIL PROTECTED]> wrote:
>> do we REALLY need dates <1900 / >2036 ?
>
> Yes.
>
>> using unix timestamps for
>> storage and as the base for all conversions would make things a lot
>> easier!
>
> datetimes are picklable, so if you are going to change how they are
> stored (which may not be a good idea for backwards compatible
> reasons), you should use that.

i'll surely change the storage format, when rewriting it! storing
year, month, day, hour, minute, second, a unix timestamp and tzinfo
is plain odd! so using a datetime instance for storage indeed seems
the most obvious thing if we need dates <1900 / >2036.

regards, juergen herrmann
___

>> XLhost.de - eXperts in Linux hosting <<

Jürgen Herrmann
Bruderwöhrdstraße 15b, DE-93051 Regensburg

Fon:  +49 (0)700 XLHOSTDE [0700 95467833]
Fax:  +49 (0)721 151 463027
WEB:  http://www.XLhost.de
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Re: DateTime mess

2005-11-22 Thread Lennart Regebro
On 11/22/05, Jürgen Herrmann <[EMAIL PROTECTED]> wrote:
> do we REALLY need dates <1900 / >2036 ?

Yes.

> using unix timestamps for
> storage and as the base for all conversions would make things a lot
> easier!

datetimes are picklable, so if you are going to change how they are
stored (which may not be a good idea for backwards compatible
reasons), you should use that.
--
Lennart Regebro, Nuxeo http://www.nuxeo.com/
CPS Content Management http://www.cps-project.org/
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists -
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Re: DateTime strftime problem

2005-11-09 Thread Jürgen Herrmann

[ Dieter Maurer wrote:]
> Jürgen Herrmann wrote at 2005-11-9 13:38 +0100:
>>zope 2.7.8's DateTime::strftime() looks like this:
>>
>>def strftime(self, format):
>>  # Format the date/time using the *local timezone representation*.
>>  return strftime(format, safelocaltime(self.timeTime()))
>>
>>it seems that my assumption about strftime's behaviour was incorrect.
>>why do we have time zones at all, if strftime always uses the machine's
>>local time zone?
>
> Zope's "strftime" is simply broken.
>
> Forget about it. It should be simple to implement your own
> version in Python (and I think someone already did).
> Once you did, donate the implementation to Zope
>
> --
> Dieter
>
ok, i guess i can fix strftime. will take some time to change the tests
and add some comments. i'd like to report with the patch here first and
get some comments, to avoid "don't do"s...

already came across another python bug in strptime, that reports a format
error, if %Z (timezone *omg*) is in the format string and you give
it value different to UTC...

this IS getting interesting :)

thanks for all your help...

regards, juergen
___

>> XLhost.de - eXperts in Linux hosting <<

Jürgen Herrmann
Bruderwöhrdstraße 15b, DE-93051 Regensburg

Fon:  +49 (0)700 XLHOSTDE [0700 95467833]
Fax:  +49 (0)721 151 463027
WEB:  http://www.XLhost.de
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Re: DateTime strftime problem

2005-11-09 Thread Dieter Maurer
Jürgen Herrmann wrote at 2005-11-9 13:38 +0100:
>zope 2.7.8's DateTime::strftime() looks like this:
>
>def strftime(self, format):
>  # Format the date/time using the *local timezone representation*.
>  return strftime(format, safelocaltime(self.timeTime()))
>
>it seems that my assumption about strftime's behaviour was incorrect.
>why do we have time zones at all, if strftime always uses the machine's
>local time zone?

Zope's "strftime" is simply broken.

Forget about it. It should be simple to implement your own
version in Python (and I think someone already did).
Once you did, donate the implementation to Zope

-- 
Dieter
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Re: DateTime strftime problem

2005-11-09 Thread Jürgen Herrmann
zope 2.7.8's DateTime::strftime() looks like this:

def strftime(self, format):
  # Format the date/time using the *local timezone representation*.
  return strftime(format, safelocaltime(self.timeTime()))

it seems that my assumption about strftime's behaviour was incorrect.
why do we have time zones at all, if strftime always uses the machine's
local time zone?
would this be better off in a new method, similar to strftime but
respecting the DateTime's current time zone? (that's what i need)

submitting a patch with my implementation is likely to be refused
because it changes long standing behaviour...

on the other hand, if DateTime's strftime should behave as similar
as possible to datetime's strftime, it should respect the timezone
information attached to it.

honestly i don't know what to do... i can just make this a monkeypatch
and only use it myself, but that just didn't feel like "the right thing
to do" :)

regards, juergen herrmann

[ Florent Guillaume wrote:]
> The DateTime implementation in Zope is notoriously undertested and
> underspecified when it comes to time zones. Until recently strftime was
> quite buggy too, and as you saw it has been recoded in terms of the python
> datetime implementation now that it exists. It's very possible that a bug
> was introduced at that point, it would be useful to check with Zope 2.7's
> DateTime. Or the bug has always been there.
>
> It think it's a good thing if DateTime can behave more regularly, which
> means be more in line with python's datetime, in corner cases.
>
> Please submit a patch to the collector. It probably will be included in
> 2.9
> but not 2.8 which is strictly in maintenance mode, unless you convince us
> that it's very unlikely that code would change behavior as a result.
>
> Florent
>
> Jürgen Herrmann wrote:
>> [ Jürgen Herrmann wrote:]
>>
>>>i looked at the source of DateTime::strftime(), surpirse, surprise :)
>>>strftime uses python's datetime class and it's strftime method!
>>>but no care is taken at this time for timezone information, so i
>>>decided to code a tzinfo subclass for datetime that can represent
>>>fixed offset from gmt (no dst) and hand one such instance to
>>>datetime.fromtimestamp(). seems like this code is working correctly now.
>>>i'll run it against some tests tomorrow and report back on the results.
>>>
>>>regards, juergen herrmann
>>
>>
>> if i run the DateTime testsuite against my patched version:
>> ==
>> ERROR: Checks strftime in dates <= 1900 or >= 2038
>> --
>> Traceback (most recent call last):
>>   File "/usr/lib/python2.4/unittest.py", line 260, in run
>> testMethod()
>>   File "/home/bliss/zope/lib/python/DateTime/tests/testDateTime.py",
>> line
>> 366, in testStrftimeFarDates
>> self.assertEqual(dt.strftime('%d/%m/%Y'), '30/01/1900')
>>   File "/home/bliss/zope/lib/python/DateTime/DateTime.py", line 1542, in
>> strftime
>> ds = datetime.fromtimestamp(self._t+offsetsecs,
>> tzi).strftime(format)
>> ValueError: timestamp out of range for platform time_t
>>
>> ==
>> ERROR: Checks time zone in dates <= 1900 or >= 2038
>> --
>> Traceback (most recent call last):
>>   File "/usr/lib/python2.4/unittest.py", line 260, in run
>> testMethod()
>>   File "/home/bliss/zope/lib/python/DateTime/tests/testDateTime.py",
>> line
>> 374, in testZoneInFarDates
>> self.assertEqual(dt1.strftime('%d/%m/%Y %H:%M'),
>> dt2.strftime('%d/%m/%Y %H:%M'))
>>   File "/home/bliss/zope/lib/python/DateTime/DateTime.py", line 1542, in
>> strftime
>> ds = datetime.fromtimestamp(self._t+offsetsecs,
>> tzi).strftime(format)
>> ValueError: timestamp out of range for platform time_t
>>
>> ==
>> FAIL: strftime timezone testing
>> --
>> Traceback (most recent call last):
>>   File "/usr/lib/python2.4/unittest.py", line 260, in run
>> testMethod()
>>   File "/home/bliss/zope/lib/python/DateTime/tests/testDateTime.py",
>> line
>> 361, in testStrftimeTZhandling
>> self.assertEqual(dt_string, dt_localstring)
>>   File "/usr/lib/python2.4/unittest.py", line 333, in failUnlessEqual
>> raise self.failureException, \
>> AssertionError: '2003-11-19 17:32 -0215' != '2003-11-19 21:47 GMT+0100'
>>
>> --
>> Ran 32 tests in 13.056s
>>
>> th first two are obviously side effects from using a timestamp for
>> the instantiation of my datetime object, could be fixed, not the focus
>> for now.
>>
>> the third one brings me back to my initial question:
>> what is this code snippet supposed to return?
>>
>d = DateTime('2005/04/03 02:01 UTC')
>d.toZone('G

Re: [Zope] Re: DateTime(), locale, summertime etc.

2005-04-09 Thread Paul Winkler
On Thu, Apr 07, 2005 at 11:22:39AM -0400, Paul Winkler wrote:
> Maybe this is relevant:
> http://www.zope.org/Collectors/CMF/325
> 
> ... crap, I never merged the fix. 

OK, now this is merged to the trunk and CMF-1_5-branch.

-- 

Paul Winkler
http://www.slinkp.com
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Re: DateTime(), locale, summertime etc.

2005-04-07 Thread Paul Winkler
On Thu, Apr 07, 2005 at 02:44:38PM +0200, Max M wrote:
> Max M wrote:
> 
> >When I convert to DateTime objects, they are saved as "9:00 Universal". 
> >So that is correct too.
> 
> Ok. Turned out that I have misunderstood zopes DateTime().
> 
> It saves in UTC, but it still needs a timezone.
> 
> So converting datetime objects to the local timezone and then converting 
> to DateTime objects also as local timezone did the trick.
> 
> hmmm

Maybe this is relevant:
http://www.zope.org/Collectors/CMF/325

... crap, I never merged the fix. 
I should really make it a habit to read the CMF issues nag mail :-0

-- 

Paul Winkler
http://www.slinkp.com
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Re: DateTime

2000-11-11 Thread Ender

Jerome Alet wrote:
> 
> On Fri, 10 Nov 2000, Chris Withers wrote:
> 
> > mxDateTime is _not_ the DateTime in Zope. If only it was
> 
> It's voting season, so I vote +10 for this one.
> 
> bye,

I'll second that 

+10

kapil

___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )




Re: [Zope] Re: DateTime

2000-11-10 Thread Jerome Alet

On Fri, 10 Nov 2000, Chris Withers wrote:

> mxDateTime is _not_ the DateTime in Zope. If only it was

It's voting season, so I vote +10 for this one.

bye,

Jerome ALET - [EMAIL PROTECTED] - http://cortex.unice.fr/~jerome
Fac de Medecine de Nicehttp://wwwmed.unice.fr 
Tel: (+33) 4 93 37 76 30 Fax: (+33) 4 93 53 15 15
28 Avenue de Valombrose - 06107 NICE Cedex 2 - FRANCE



___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )