Merge from trunk

This commit is contained in:
Charles Haley 2011-03-04 18:31:31 +00:00
commit 0868ec5846
2 changed files with 7 additions and 7 deletions

View File

@ -38,17 +38,17 @@ def _c_convert_timestamp(val):
ret = None ret = None
if ret is None: if ret is None:
return parse_date(val, as_utc=False) return parse_date(val, as_utc=False)
year, month, day, hour, minutes, seconds, tzmins = ret year, month, day, hour, minutes, seconds, tzsecs = ret
return datetime(year, month, day, hour, minutes, seconds, return datetime(year, month, day, hour, minutes, seconds,
tzinfo=tzoffset(None, tzmins)).astimezone(local_tz) tzinfo=tzoffset(None, tzsecs)).astimezone(local_tz)
def _py_convert_timestamp(val): def _py_convert_timestamp(val):
if val: if val:
tzmins = 0 tzsecs = 0
try: try:
sign = {'+':1, '-':-1}.get(val[-6], None) sign = {'+':1, '-':-1}.get(val[-6], None)
if sign is not None: if sign is not None:
tzmins = (int(val[-5:-3])*60 + int(val[-2:])) * sign tzsecs = 60*((int(val[-5:-3])*60 + int(val[-2:])) * sign)
year = int(val[0:4]) year = int(val[0:4])
month = int(val[5:7]) month = int(val[5:7])
day = int(val[8:10]) day = int(val[8:10])
@ -56,7 +56,7 @@ def _py_convert_timestamp(val):
min = int(val[14:16]) min = int(val[14:16])
sec = int(val[17:19]) sec = int(val[17:19])
return datetime(year, month, day, hour, min, sec, return datetime(year, month, day, hour, min, sec,
tzinfo=tzoffset(None, tzmins)).astimezone(local_tz) tzinfo=tzoffset(None, tzsecs))
except: except:
pass pass
return parse_date(val, as_utc=False) return parse_date(val, as_utc=False)

View File

@ -45,7 +45,7 @@ speedup_parse_date(PyObject *self, PyObject *args) {
tz = orig + len - 6; tz = orig + len - 6;
if (*tz == '+') sign = 1; if (*tz == '+') sign = +1;
if (*tz == '-') sign = -1; if (*tz == '-') sign = -1;
if (sign != 0) { if (sign != 0) {
// We have TZ info // We have TZ info
@ -60,7 +60,7 @@ speedup_parse_date(PyObject *self, PyObject *args) {
} }
return Py_BuildValue("lllllll", year, month, day, hour, minute, second, return Py_BuildValue("lllllll", year, month, day, hour, minute, second,
(tzh*60 + tzm)*sign); (tzh*60 + tzm)*sign*60);
} }
static PyMethodDef speedup_methods[] = { static PyMethodDef speedup_methods[] = {