commit
d7ce6b280e
@ -3,7 +3,7 @@
|
||||
|
||||
import re
|
||||
from time import time, mktime
|
||||
from datetime import datetime, date
|
||||
from datetime import datetime
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
||||
search_re = re.compile(r'^([^-]+)-([^-/]+)(/(.*))?$')
|
||||
@ -145,11 +145,9 @@ class croniter(object):
|
||||
|
||||
def _calc(self, now, expanded, is_prev):
|
||||
if is_prev:
|
||||
nearest_method = self._get_prev_nearest
|
||||
nearest_diff_method = self._get_prev_nearest_diff
|
||||
sign = -1
|
||||
else:
|
||||
nearest_method = self._get_next_nearest
|
||||
nearest_diff_method = self._get_next_nearest_diff
|
||||
sign = 1
|
||||
|
||||
@ -232,7 +230,7 @@ class croniter(object):
|
||||
if expanded[5][0] != '*':
|
||||
diff_sec = nearest_diff_method(d.second, expanded[5], 60)
|
||||
if diff_sec != None and diff_sec != 0:
|
||||
dst += relativedelta(seconds = diff_sec)
|
||||
d += relativedelta(seconds = diff_sec)
|
||||
return True, d
|
||||
else:
|
||||
d += relativedelta(second = 0)
|
||||
|
@ -2,8 +2,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import unittest
|
||||
import time
|
||||
from datetime import datetime, date
|
||||
from datetime import datetime
|
||||
from croniter import croniter
|
||||
|
||||
class CroniterTest(unittest.TestCase):
|
||||
@ -120,7 +119,6 @@ class CroniterTest(unittest.TestCase):
|
||||
self.assertEqual(n4.year, 2011)
|
||||
|
||||
def testError(self):
|
||||
base = datetime(2010, 1, 25)
|
||||
itr = croniter('* * * * *')
|
||||
self.assertRaises(TypeError, itr.get_next, str)
|
||||
self.assertRaises(ValueError, croniter, '* * * *')
|
||||
@ -179,7 +177,7 @@ class CroniterTest(unittest.TestCase):
|
||||
self.assertEqual(prev3.hour, 0)
|
||||
self.assertEqual(prev3.minute, 0)
|
||||
|
||||
def testPrevWeekDay(self):
|
||||
def testPrevWeekDay2(self):
|
||||
base = datetime(2010, 8, 25, 15, 56)
|
||||
itr = croniter('10 0 * * 0', base)
|
||||
prev = itr.get_prev(datetime)
|
||||
|
Loading…
Reference in New Issue
Block a user