Re: [Zope] DateTime strftime problem

2005-11-09 Thread Chris Withers

Jürgen Herrmann wrote:


hmm, could i please have a comment on my real question? is it correct,
to expect the abovementioned retval from strftime in this case?
if so, i'll change the testcase and fix the two outstanding issues
with dates 1900 or 2035 and open a collector issue with the patches
included.


My point was that no, I can't comment on your real question. Too many 
people just dive in and change things so the tests pass without really 
looking closely at what they're doing. This is likely how DateTime got 
to be such a mess in the first place: works for me, must be okay!


It's good to see someone paying some decent attention to this, I just 
hope you're paying real close attention and really understand the 
problem, 'cos it's a damn hard problem...


cheers,

Chris

--
Simplistix - Content Management, Zope  Python Consulting
   - http://www.simplistix.co.uk

___
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] DateTime strftime problem

2005-11-08 Thread Jürgen Herrmann

[ Andreas Jung wrote:]


 --On 7. November 2005 15:36:26 +0100 Andreas Jung [EMAIL PROTECTED]
 wrote:



 --On 7. November 2005 15:22:56 +0100 Jürgen Herrmann
 [EMAIL PROTECTED] wrote:

 2. if this works as expected, why not make DateTime a wrapper around
 python datetime objects? is DateTime optimized for storage in the
 zodb (maybe a separate question to the zodb-dev list)?
 what was the intention to create DateTime anyway, if there's a
 python pendant already?


 This idea had been discussed already for Python 2.4 or Python 2.5

 I mean: Zope 2.4 or Zope 2.5, not Python 

 -aj

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
___

 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] DateTime strftime problem

2005-11-08 Thread Jürgen Herrmann
[ 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('GMT+1').strftime('%Y/%m/%d %H:%M %Z')
'2005/04/03 03:01 GMT+0100'

is this correct?

if so, the i would tend to say, the testcase was written to pass with
wrong strftime() behaviour. (*duck*)

regards, juergen herrmann

ps: tomorrow has been shifted to today due to a bug in my brain's
datetime implementation, so i ran the tests today :)
___

 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] DateTime strftime problem

2005-11-08 Thread Chris Withers

Andreas Jung wrote:


This idea had been discussed already for Python 2.4 or Python 2.5 I think.
Since 100% compatibility could not  be guaranteed, 


What? you mean it wouldn't be broken? ;-)

Chris

--
Simplistix - Content Management, Zope  Python Consulting
   - http://www.simplistix.co.uk
___
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] DateTime strftime problem

2005-11-08 Thread Chris Withers

Jürgen Herrmann wrote:

d = DateTime('2005/04/03 02:01 UTC')
d.toZone('GMT+1').strftime('%Y/%m/%d %H:%M %Z')


'2005/04/03 03:01 GMT+0100'

is this correct?

if so, the i would tend to say, the testcase was written to pass with
wrong strftime() behaviour. 


That would be entirely unsuprising *sigh*

Chris - hey! it passes the tests! it must be right! yeah...

--
Simplistix - Content Management, Zope  Python Consulting
   - http://www.simplistix.co.uk
___
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] DateTime strftime problem

2005-11-07 Thread Andreas Jung



--On 7. November 2005 14:21:32 +0100 Jürgen Herrmann 
[EMAIL PROTECTED] wrote:



hi all!

DateTime('2005/04/03 02:01 GMT').toZone('GMT-4')

prints:
2005/04/02 22:01:00 GMT-4
...which is what i expected
-
DateTime('2005/04/03 02:01 GMT').toZone('GMT-4')\
.strftime('%Y/%m/%d %H:%M %Z')

prints:
2005/04/03 04:01



Which Zope version?

-aj



pgpNw1dkVSwcN.pgp
Description: PGP signature
___
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] DateTime strftime problem

2005-11-07 Thread Jürgen Herrmann

[ Andreas Jung wrote:]


 --On 7. November 2005 14:41:43 +0100 Jürgen Herrmann
 zope 2.8.3, should i upgrade to 2.8.4 first?


 This is possibly related to bug #1780 (and other related timezone bugs).
 Unfortunately the timezone handling in Zope was and is always a
 mess...unlikely that it will be ever fixed, sorry.

 -aj



then i will fix it, if i can. i need that functionality, because we
have users from different time zones that access a shared calendar.

thanks for the hint anyway,
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] DateTime strftime problem

2005-11-07 Thread Andreas Jung



--On 7. November 2005 14:59:44 +0100 Jürgen Herrmann 
[EMAIL PROTECTED] wrote:





then i will fix it, if i can. i need that functionality, because we
have users from different time zones that access a shared calendar.



The if i can might be the reason why is not fixed yet :-) But feel free
to submit patches, good luck.

-aj



pgpk69zyt6jDD.pgp
Description: PGP signature
___
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] DateTime strftime problem

2005-11-07 Thread Jürgen Herrmann

[ Andreas Jung wrote:]


 --On 7. November 2005 14:41:43 +0100 Jürgen Herrmann
 zope 2.8.3, should i upgrade to 2.8.4 first?


 This is possibly related to bug #1780 (and other related timezone bugs).
 Unfortunately the timezone handling in Zope was and is always a
 mess...unlikely that it will be ever fixed, sorry.

 -aj


me once again...

d = DateTime('2005/04/03 02:01 GMT').toZone('GMT+1')
s = d.strftime('%Y/%m/%d %H:%M %Z')

here i would expect s == '2005/04/03 03:01 GMT+1',
do i have the correct expectation here?

what is d.strftime('%Y/%m/%d %H:%M') expected to return then?

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] DateTime strftime problem

2005-11-07 Thread Lennart Regebro
On 11/7/05, Jürgen Herrmann [EMAIL PROTECTED] wrote:

 then i will fix it, if i can. i need that functionality, because we
 have users from different time zones that access a shared calendar.

I don't know if this helps, but it might:

Python had a good module called datetime. Most likely, you want to use
that instead.  There are no standard timezone implementation, but Zope
3 has one you might be able to use.

--
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] DateTime strftime problem

2005-11-07 Thread Jürgen Herrmann

[ Lennart Regebro wrote:]
 On 11/7/05, Jürgen Herrmann [EMAIL PROTECTED] wrote:

 then i will fix it, if i can. i need that functionality, because we
 have users from different time zones that access a shared calendar.

 I don't know if this helps, but it might:

 Python had a good module called datetime. Most likely, you want to use
 that instead.  There are no standard timezone implementation, but Zope
 3 has one you might be able to use.

1. what do you mean by HAD? seems to be there still and looks quite
useable.
2. if this works as expected, why not make DateTime a wrapper around
python datetime objects? is DateTime optimized for storage in the
zodb (maybe a separate question to the zodb-dev list)?
what was the intention to create DateTime anyway, if there's a
python pendant already?

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] DateTime strftime problem

2005-11-07 Thread Andreas Jung



--On 7. November 2005 15:22:56 +0100 Jürgen Herrmann 
[EMAIL PROTECTED] wrote:



2. if this works as expected, why not make DateTime a wrapper around
python datetime objects? is DateTime optimized for storage in the
zodb (maybe a separate question to the zodb-dev list)?
what was the intention to create DateTime anyway, if there's a
python pendant already?



This idea had been discussed already for Python 2.4 or Python 2.5 I think.
Since 100% compatibility could not  be guaranteed, it was never implemented

-aj


pgpTB52BlFmar.pgp
Description: PGP signature
___
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] DateTime strftime problem

2005-11-07 Thread Lennart Regebro
On 11/7/05, Jürgen Herrmann [EMAIL PROTECTED] wrote:

 1. what do you mean by HAD? seems to be there still and looks quite
 useable.

I mean has. :)

 2. if this works as expected, why not make DateTime a wrapper around
 python datetime objects?

Because that is a lot of work to make that work in a way that doesn't
instantly break every Zope instance in existance.

 what was the intention to create DateTime anyway, if there's a
 python pendant already?

It didn't exist then.

--
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] DateTime strftime problem

2005-11-07 Thread Andreas Jung



--On 7. November 2005 15:36:26 +0100 Andreas Jung [EMAIL PROTECTED] 
wrote:





--On 7. November 2005 15:22:56 +0100 Jürgen Herrmann
[EMAIL PROTECTED] wrote:


2. if this works as expected, why not make DateTime a wrapper around
python datetime objects? is DateTime optimized for storage in the
zodb (maybe a separate question to the zodb-dev list)?
what was the intention to create DateTime anyway, if there's a
python pendant already?



This idea had been discussed already for Python 2.4 or Python 2.5


I mean: Zope 2.4 or Zope 2.5, not Python 

-aj

pgpb3HMx1OzLD.pgp
Description: PGP signature
___
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] DateTime strftime problem

2005-11-07 Thread Ron Bickers
On Mon November 7 2005 08:21 am, Jürgen Herrmann wrote:

 DateTime('2005/04/03 02:01 GMT').toZone('GMT-4')

 prints:
 2005/04/02 22:01:00 GMT-4
 ...which is what i expected
 -
 DateTime('2005/04/03 02:01 GMT').toZone('GMT-4')\
 .strftime('%Y/%m/%d %H:%M %Z')

 prints:
 2005/04/03 04:01

 hmm, where's the timezone information gone? to make it short, how
 can i get a text representation of a DateTime object in a given
 timezone?

strftime() timezone is broken in all versions of Zope that I know of.  You 
can work around it by using the individual functions to get the information.  
For example (not verified):

  dt = DateTime('2005/04/03 02:01 GMT').toZone('GMT-4')
  '%s/%s/%s %s:%s %s' % (dt.year(), dt.month(), dt.day(),
 dt.hour(), dt.minute, dt.timezone())

or, if you throw the seconds in there and you keep them in the same order, 
you can just use parts():

  '%s/%s/%s %s:%s:%s %s' % (dt.parts())

-- 
Ron
___
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] DateTime strftime problem

2005-11-07 Thread Ron Bickers
On Mon November 7 2005 12:15 pm, Ron Bickers wrote:

   dt = DateTime('2005/04/03 02:01 GMT').toZone('GMT-4')
   '%s/%s/%s %s:%s %s' % (dt.year(), dt.month(), dt.day(),
  dt.hour(), dt.minute, dt.timezone())

   '%s/%s/%s %s:%s:%s %s' % (dt.parts())

Uh... you'll probably need to change the format string to suit your needs of 
leading zeros and such, but you get the idea.

-- 
Ron
___
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] DateTime strftime problem

2005-11-07 Thread Ron Bickers
On Mon November 7 2005 12:15 pm, Ron Bickers wrote:

   dt = DateTime('2005/04/03 02:01 GMT').toZone('GMT-4')
   '%s/%s/%s %s:%s %s' % (dt.year(), dt.month(), dt.day(),
  dt.hour(), dt.minute, dt.timezone())

Oops. A (hopefully obvious) typo... should be dt.minute()

-- 
Ron
___
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 )