Skip to content

Commit 456694e

Browse files
author
Richard Jones
committed
merge from HEAD
1 parent 318ae5e commit 456694e

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

CHANGES.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ Fixed:
1010
- less specific messages for login failures (thanks Chris Withers)
1111
- Reject raised against email messages should result in email rejection, not
1212
discarding of the message
13-
- mailgw can override the MAIL_DEFUALT_CLASS
13+
- mailgw can override the MAIL_DEFAULT_CLASS
14+
- handle Py2.3+ datetime objects as Date specs (sf bug 971300)
1415

1516

1617
2004-07-21 0.7.6

doc/index.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ Roy Rapoport,
117117
John P. Rouillard,
118118
Ollie Rutherfurd,
119119
Toby Sargeant,
120+
Gregor Schmid,
120121
Florian Schulze,
121122
Klamer Schutte,
122123
Dougal Scott,

roundup/date.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: date.py,v 1.68.2.2 2004-07-04 09:08:55 richard Exp $
18+
# $Id: date.py,v 1.68.2.3 2004-09-29 07:31:32 richard Exp $
1919

2020
"""Date, time and time interval handling.
2121
"""
@@ -25,6 +25,12 @@
2525
from types import *
2626
from i18n import _
2727

28+
try:
29+
import datetime
30+
have_datetime = 1
31+
except:
32+
have_datetime = 0
33+
2834
def _add_granularity(src, order, value = 1):
2935
'''Increment first non-None value in src dictionary ordered by 'order'
3036
parameter
@@ -121,6 +127,11 @@ def __init__(self, spec='.', offset=0, add_granularity=0):
121127
if type(spec) == type(''):
122128
self.set(spec, offset=offset, add_granularity=add_granularity)
123129
return
130+
elif have_datetime and isinstance(spec, datetime.datetime):
131+
# Python 2.3+ datetime object
132+
y,m,d,H,M,S,x,x,x = spec.timetuple()
133+
S += spec.microsecond/1000000.
134+
spec = (y,m,d,H,M,S,x,x,x)
124135
elif hasattr(spec, 'tuple'):
125136
spec = spec.tuple()
126137
elif isinstance(spec, Date):

test/test_dates.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: test_dates.py,v 1.32 2004-04-18 05:31:03 richard Exp $
18+
# $Id: test_dates.py,v 1.32.2.1 2004-09-29 07:31:32 richard Exp $
1919
from __future__ import nested_scopes
2020

2121
import unittest, time
@@ -372,6 +372,14 @@ def ae(spec, pretty):
372372
ae('-1y', '1 year ago')
373373
ae('-2y', '2 years ago')
374374

375+
def testPyDatetime(self):
376+
try:
377+
import datetime
378+
except:
379+
return
380+
d = datetime.datetime.now()
381+
Date(d)
382+
375383
def test_suite():
376384
suite = unittest.TestSuite()
377385
suite.addTest(unittest.makeSuite(DateTestCase))

0 commit comments

Comments
 (0)