python-dateutil
Advanced tools
| """ | ||
| Contains information about the dateutil version. | ||
| """ | ||
| VERSION_MAJOR = 2 | ||
| VERSION_MINOR = 6 | ||
| VERSION_PATCH = 1 | ||
| VERSION_TUPLE = (VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH) | ||
| VERSION = '.'.join(map(str, VERSION_TUPLE)) |
| # -*- coding: utf-8 -*- | ||
| __version__ = "2.6.0" | ||
| from ._version import VERSION as __version__ |
@@ -5,2 +5,3 @@ """ | ||
| class weekday(object): | ||
@@ -7,0 +8,0 @@ __slots__ = ["weekday", "n"] |
+39
-25
@@ -1,2 +0,2 @@ | ||
| # -*- coding:iso-8859-1 -*- | ||
| # -*- coding: utf-8 -*- | ||
| """ | ||
@@ -38,3 +38,3 @@ This module offers a generic date/time string parser which is able to parse | ||
| from io import StringIO | ||
| from calendar import monthrange, isleap | ||
| from calendar import monthrange | ||
@@ -51,3 +51,3 @@ from six import text_type, binary_type, integer_types | ||
| # Fractional seconds are sometimes split by a comma | ||
| _split_decimal = re.compile("([\.,])") | ||
| _split_decimal = re.compile("([.,])") | ||
@@ -314,3 +314,3 @@ def __init__(self, instream): | ||
| def weekday(self, name): | ||
| if len(name) >= 3: | ||
| if len(name) >= min(len(n) for n in self._weekdays.keys()): | ||
| try: | ||
@@ -323,3 +323,3 @@ return self._weekdays[name.lower()] | ||
| def month(self, name): | ||
| if len(name) >= 3: | ||
| if len(name) >= min(len(n) for n in self._months.keys()): | ||
| try: | ||
@@ -548,2 +548,5 @@ return self._months[name.lower()] + 1 | ||
| :raises TypeError: | ||
| Raised for non-string or character stream input. | ||
| :raises OverflowError: | ||
@@ -555,7 +558,4 @@ Raised if the parsed date exceeds the largest valid C integer on | ||
| if default is None: | ||
| effective_dt = datetime.datetime.now() | ||
| default = datetime.datetime.now().replace(hour=0, minute=0, | ||
| second=0, microsecond=0) | ||
| else: | ||
| effective_dt = default | ||
@@ -802,14 +802,18 @@ res, skipped_tokens = self._parse(timestr, **kwargs) | ||
| # X h MM or X m SS | ||
| idx = info.hms(l[i-3]) + 1 | ||
| idx = info.hms(l[i-3]) | ||
| if idx == 1: | ||
| if idx == 0: # h | ||
| res.minute = int(value) | ||
| if value % 1: | ||
| res.second = int(60*(value % 1)) | ||
| elif idx == 2: | ||
| res.second, res.microsecond = \ | ||
| _parsems(value_repr) | ||
| i += 1 | ||
| sec_remainder = value % 1 | ||
| if sec_remainder: | ||
| res.second = int(60 * sec_remainder) | ||
| elif idx == 1: # m | ||
| res.second, res.microsecond = \ | ||
| _parsems(value_repr) | ||
| # We don't need to advance the tokens here because the | ||
| # i == len_l call indicates that we're looking at all | ||
| # the tokens already. | ||
| elif i+1 < len_l and l[i] == ':': | ||
@@ -962,3 +966,3 @@ # HH:MM[:SS[.ss]] | ||
| elif not 0 <= res.hour <= 12: | ||
| # If AM/PM is found, it's a 12 hour clock, so raise | ||
| # If AM/PM is found, it's a 12 hour clock, so raise | ||
| # an error for invalid range | ||
@@ -979,2 +983,5 @@ if fuzzy: | ||
| elif fuzzy: | ||
| last_skipped_token_i = self._skip_token(skipped_tokens, | ||
| last_skipped_token_i, i, l) | ||
| i += 1 | ||
@@ -1044,9 +1051,4 @@ continue | ||
| if last_skipped_token_i == i - 1: | ||
| # recombine the tokens | ||
| skipped_tokens[-1] += l[i] | ||
| else: | ||
| # just append | ||
| skipped_tokens.append(l[i]) | ||
| last_skipped_token_i = i | ||
| last_skipped_token_i = self._skip_token(skipped_tokens, | ||
| last_skipped_token_i, i, l) | ||
| i += 1 | ||
@@ -1077,2 +1079,14 @@ | ||
| @staticmethod | ||
| def _skip_token(skipped_tokens, last_skipped_token_i, i, l): | ||
| if last_skipped_token_i == i - 1: | ||
| # recombine the tokens | ||
| skipped_tokens[-1] += l[i] | ||
| else: | ||
| # just append | ||
| skipped_tokens.append(l[i]) | ||
| last_skipped_token_i = i | ||
| return last_skipped_token_i | ||
| DEFAULTPARSER = parser() | ||
@@ -1159,3 +1173,3 @@ | ||
| >>> parse("Today is January 1, 2047 at 8:21:00AM", fuzzy_with_tokens=True) | ||
| (datetime.datetime(2011, 1, 1, 8, 21), (u'Today is ', u' ', u'at ')) | ||
| (datetime.datetime(2047, 1, 1, 8, 21), (u'Today is ', u' ', u'at ')) | ||
@@ -1162,0 +1176,0 @@ :return: |
@@ -13,3 +13,3 @@ # -*- coding: utf-8 -*- | ||
| MO, TU, WE, TH, FR, SA, SU = weekdays = tuple([weekday(x) for x in range(7)]) | ||
| MO, TU, WE, TH, FR, SA, SU = weekdays = tuple(weekday(x) for x in range(7)) | ||
@@ -190,3 +190,2 @@ __all__ = ["relativedelta", "MO", "TU", "WE", "TH", "FR", "SA", "SU"] | ||
| if isinstance(weekday, integer_types): | ||
@@ -256,2 +255,3 @@ self.weekday = weekdays[weekday] | ||
| return self.days // 7 | ||
| @weeks.setter | ||
@@ -317,10 +317,18 @@ def weeks(self, value): | ||
| leapdays=other.leapdays or self.leapdays, | ||
| year=other.year or self.year, | ||
| month=other.month or self.month, | ||
| day=other.day or self.day, | ||
| weekday=other.weekday or self.weekday, | ||
| hour=other.hour or self.hour, | ||
| minute=other.minute or self.minute, | ||
| second=other.second or self.second, | ||
| microsecond=(other.microsecond or | ||
| year=(other.year if other.year is not None | ||
| else self.year), | ||
| month=(other.month if other.month is not None | ||
| else self.month), | ||
| day=(other.day if other.day is not None | ||
| else self.day), | ||
| weekday=(other.weekday if other.weekday is not None | ||
| else self.weekday), | ||
| hour=(other.hour if other.hour is not None | ||
| else self.hour), | ||
| minute=(other.minute if other.minute is not None | ||
| else self.minute), | ||
| second=(other.second if other.second is not None | ||
| else self.second), | ||
| microsecond=(other.microsecond if other.microsecond | ||
| is not None else | ||
| self.microsecond)) | ||
@@ -403,10 +411,19 @@ if isinstance(other, datetime.timedelta): | ||
| leapdays=self.leapdays or other.leapdays, | ||
| year=self.year or other.year, | ||
| month=self.month or other.month, | ||
| day=self.day or other.day, | ||
| weekday=self.weekday or other.weekday, | ||
| hour=self.hour or other.hour, | ||
| minute=self.minute or other.minute, | ||
| second=self.second or other.second, | ||
| microsecond=self.microsecond or other.microsecond) | ||
| year=(self.year if self.year is not None | ||
| else other.year), | ||
| month=(self.month if self.month is not None else | ||
| other.month), | ||
| day=(self.day if self.day is not None else | ||
| other.day), | ||
| weekday=(self.weekday if self.weekday is not None else | ||
| other.weekday), | ||
| hour=(self.hour if self.hour is not None else | ||
| other.hour), | ||
| minute=(self.minute if self.minute is not None else | ||
| other.minute), | ||
| second=(self.second if self.second is not None else | ||
| other.second), | ||
| microsecond=(self.microsecond if self.microsecond | ||
| is not None else | ||
| other.microsecond)) | ||
@@ -533,2 +550,3 @@ def __neg__(self): | ||
| def _sign(x): | ||
@@ -535,0 +553,0 @@ return int(copysign(1, x)) |
+23
-20
@@ -49,3 +49,3 @@ # -*- coding: utf-8 -*- | ||
| FREQNAMES = ['YEARLY','MONTHLY','WEEKLY','DAILY','HOURLY','MINUTELY','SECONDLY'] | ||
| FREQNAMES = ['YEARLY', 'MONTHLY', 'WEEKLY', 'DAILY', 'HOURLY', 'MINUTELY', 'SECONDLY'] | ||
@@ -64,2 +64,3 @@ (YEARLY, | ||
| class weekday(weekdaybase): | ||
@@ -75,5 +76,6 @@ """ | ||
| MO, TU, WE, TH, FR, SA, SU = weekdays = tuple([weekday(x) for x in range(7)]) | ||
| MO, TU, WE, TH, FR, SA, SU = weekdays = tuple(weekday(x) for x in range(7)) | ||
| def _invalidates_cache(f): | ||
@@ -262,9 +264,9 @@ """ | ||
| if comp(d, dt): | ||
| yield d | ||
| if count is not None: | ||
| n += 1 | ||
| if n >= count: | ||
| if n > count: | ||
| break | ||
| yield d | ||
| def between(self, after, before, inc=False, count=1): | ||
@@ -370,3 +372,3 @@ """ Returns all the occurrences of the rrule between after and before. | ||
| ``until`` parameter. | ||
| .. note:: | ||
@@ -452,3 +454,3 @@ As of version 2.5.0, the use of the ``until`` keyword together | ||
| if count and until: | ||
| if count is not None and until: | ||
| warn("Using both 'count' and 'until' is inconsistent with RFC 2445" | ||
@@ -542,4 +544,4 @@ " and has been deprecated in dateutil. Future versions will " | ||
| self._bymonthday = tuple(sorted([x for x in bymonthday if x > 0])) | ||
| self._bynmonthday = tuple(sorted([x for x in bymonthday if x < 0])) | ||
| self._bymonthday = tuple(sorted(x for x in bymonthday if x > 0)) | ||
| self._bynmonthday = tuple(sorted(x for x in bymonthday if x < 0)) | ||
@@ -699,3 +701,3 @@ # Storing positive numbers first, then negative numbers | ||
| if self._count: | ||
| if self._count is not None: | ||
| parts.append('COUNT=' + str(self._count)) | ||
@@ -756,3 +758,2 @@ | ||
| def _iter(self): | ||
@@ -856,9 +857,9 @@ year, month, day, hour, minute, second, weekday, yearday, _ = \ | ||
| elif res >= self._dtstart: | ||
| total += 1 | ||
| yield res | ||
| if count: | ||
| if count is not None: | ||
| count -= 1 | ||
| if not count: | ||
| if count < 0: | ||
| self._len = total | ||
| return | ||
| total += 1 | ||
| yield res | ||
| else: | ||
@@ -874,10 +875,11 @@ for i in dayset[start:end]: | ||
| elif res >= self._dtstart: | ||
| total += 1 | ||
| yield res | ||
| if count: | ||
| if count is not None: | ||
| count -= 1 | ||
| if not count: | ||
| if count < 0: | ||
| self._len = total | ||
| return | ||
| total += 1 | ||
| yield res | ||
| # Handle frequency and interval | ||
@@ -1569,3 +1571,3 @@ fixday = False | ||
| if parm != "VALUE=DATE-TIME": | ||
| raise ValueError("unsupported RDATE parm: "+parm) | ||
| raise ValueError("unsupported EXDATE parm: "+parm) | ||
| exdatevals.append(value) | ||
@@ -1617,4 +1619,5 @@ elif name == "DTSTART": | ||
| rrulestr = _rrulestr() | ||
| # vim:ts=4:sw=4:et |
@@ -195,3 +195,3 @@ from __future__ import unicode_literals | ||
| ctzname, err = p.communicate() | ||
| ctzname = ctzname.decode() # Popen returns | ||
| ctzname = ctzname.decode() # Popen returns | ||
@@ -221,2 +221,3 @@ if p.returncode: | ||
| total_seconds = getattr(datetime.timedelta, 'total_seconds', _total_seconds) | ||
@@ -250,2 +251,3 @@ | ||
| NotAValue = NotAValueClass() | ||
@@ -284,4 +286,6 @@ | ||
| ComparesEqual = ComparesEqualClass() | ||
| class UnsetTzClass(object): | ||
@@ -291,3 +295,3 @@ """ Sentinel class for unset time zone variable """ | ||
| UnsetTz = UnsetTzClass() | ||
@@ -8,3 +8,14 @@ import sys | ||
| class ImportVersionTest(unittest.TestCase): | ||
| """ Test that dateutil.__version__ can be imported""" | ||
| def testImportVersionStr(self): | ||
| from dateutil import __version__ | ||
| def testImportRoot(self): | ||
| import dateutil | ||
| self.assertTrue(hasattr(dateutil, '__version__')) | ||
| class ImportEasterTest(unittest.TestCase): | ||
@@ -132,5 +143,11 @@ """ Test that dateutil.easter-related imports work properly """ | ||
| def testTzwinStar(self): | ||
| tzwin_all = ["tzwin", "tzwinlocal"] | ||
| from dateutil.tzwin import tzwin | ||
| from dateutil.tzwin import tzwinlocal | ||
| tzwin_all = [tzwin, tzwinlocal] | ||
| for var in tzwin_all: | ||
| self.assertIsNot(var, None) | ||
| class ImportZoneInfoTest(unittest.TestCase): | ||
@@ -137,0 +154,0 @@ def testZoneinfoDirect(self): |
@@ -5,11 +5,11 @@ # -*- coding: utf-8 -*- | ||
| from datetime import datetime, timedelta, date | ||
| from datetime import datetime, timedelta | ||
| from dateutil.tz import tzoffset | ||
| from dateutil.parser import * | ||
| from dateutil.parser import parse, parserinfo | ||
| import six | ||
| from six import assertRaisesRegex, PY3 | ||
| from six.moves import StringIO | ||
| class ParserTest(unittest.TestCase): | ||
@@ -23,10 +23,4 @@ | ||
| # Parser should be able to handle bytestring and unicode | ||
| base_str = '2014-05-01 08:00:00' | ||
| try: | ||
| # Python 2.x | ||
| self.uni_str = unicode(base_str) | ||
| self.str_str = str(base_str) | ||
| except NameError: | ||
| self.uni_str = str(base_str) | ||
| self.str_str = bytes(base_str.encode()) | ||
| self.uni_str = '2014-05-01 08:00:00' | ||
| self.str_str = self.uni_str.encode() | ||
@@ -56,3 +50,2 @@ def testEmptyString(self): | ||
| dstr = StringPassThrough(StringIO('2014 January 19')) | ||
@@ -118,3 +111,2 @@ | ||
| def testDateCommandFormatReversed(self): | ||
@@ -132,2 +124,3 @@ self.assertEqual(parse("2003 10:36:28 BRST 25 Sep Thu", | ||
| tzinfo=self.brsttz)) | ||
| def testDateCommandFormatIgnoreTz(self): | ||
@@ -467,2 +460,22 @@ self.assertEqual(parse("Thu Sep 25 10:36:28 BRST 2003", | ||
| def testHourWithLetterStrip5(self): | ||
| self.assertEqual(parse("10 h 36.5", default=self.default), | ||
| datetime(2003, 9, 25, 10, 36, 30)) | ||
| def testMinuteWithLettersSpaces1(self): | ||
| self.assertEqual(parse("36 m 5", default=self.default), | ||
| datetime(2003, 9, 25, 0, 36, 5)) | ||
| def testMinuteWithLettersSpaces2(self): | ||
| self.assertEqual(parse("36 m 5 s", default=self.default), | ||
| datetime(2003, 9, 25, 0, 36, 5)) | ||
| def testMinuteWithLettersSpaces3(self): | ||
| self.assertEqual(parse("36 m 05", default=self.default), | ||
| datetime(2003, 9, 25, 0, 36, 5)) | ||
| def testMinuteWithLettersSpaces4(self): | ||
| self.assertEqual(parse("36 m 05 s", default=self.default), | ||
| datetime(2003, 9, 25, 0, 36, 5)) | ||
| def testAMPMNoHour(self): | ||
@@ -560,5 +573,5 @@ with self.assertRaises(ValueError): | ||
| def testFuzzyWithTokens(self): | ||
| s = "Today is 25 of September of 2003, exactly " \ | ||
| s1 = "Today is 25 of September of 2003, exactly " \ | ||
| "at 10:49:41 with timezone -03:00." | ||
| self.assertEqual(parse(s, fuzzy_with_tokens=True), | ||
| self.assertEqual(parse(s1, fuzzy_with_tokens=True), | ||
| (datetime(2003, 9, 25, 10, 49, 41, | ||
@@ -569,2 +582,7 @@ tzinfo=self.brsttz), | ||
| s2 = "http://biz.yahoo.com/ipo/p/600221.html" | ||
| self.assertEqual(parse(s2, fuzzy_with_tokens=True), | ||
| (datetime(2060, 2, 21, 0, 0, 0), | ||
| ('http://biz.yahoo.com/ipo/p/', '.html'))) | ||
| def testFuzzyAMPMProblem(self): | ||
@@ -749,7 +767,7 @@ # Sometimes fuzzy parsing results in AM/PM flag being set without | ||
| def testUnspecifiedDayFallbackFebNoLeapYear(self): | ||
| def testUnspecifiedDayFallbackFebNoLeapYear(self): | ||
| self.assertEqual(parse("Feb 2007", default=datetime(2010, 1, 31)), | ||
| datetime(2007, 2, 28)) | ||
| def testUnspecifiedDayFallbackFebLeapYear(self): | ||
| def testUnspecifiedDayFallbackFebLeapYear(self): | ||
| self.assertEqual(parse("Feb 2008", default=datetime(2010, 1, 31)), | ||
@@ -820,2 +838,21 @@ datetime(2008, 2, 29)) | ||
| def testCustomParserShortDaynames(self): | ||
| # Horacio Hoyos discovered that day names shorter than 3 characters, | ||
| # for example two letter German day name abbreviations, don't work: | ||
| # https://github.com/dateutil/dateutil/issues/343 | ||
| from dateutil.parser import parserinfo, parser | ||
| class GermanParserInfo(parserinfo): | ||
| WEEKDAYS = [("Mo", "Montag"), | ||
| ("Di", "Dienstag"), | ||
| ("Mi", "Mittwoch"), | ||
| ("Do", "Donnerstag"), | ||
| ("Fr", "Freitag"), | ||
| ("Sa", "Samstag"), | ||
| ("So", "Sonntag")] | ||
| myparser = parser(GermanParserInfo()) | ||
| dt = myparser.parse("Sa 21. Jan 2017") | ||
| self.assertEqual(dt, datetime(2017, 1, 21)) | ||
| def testNoYearFirstNoDayFirst(self): | ||
@@ -864,3 +901,3 @@ dtstr = '090107' | ||
| dtstr = '2015 09 25' | ||
| self.assertEqual(parse(dtstr, dayfirst=True), | ||
| self.assertEqual(parse(dtstr, dayfirst=True), | ||
| datetime(2015, 9, 25)) | ||
@@ -872,2 +909,1 @@ | ||
| datetime(2015, 9, 25)) | ||
@@ -8,3 +8,3 @@ # -*- coding: utf-8 -*- | ||
| from dateutil.relativedelta import * | ||
| from dateutil.relativedelta import relativedelta, MO, TU, WE, FR, SU | ||
@@ -184,2 +184,8 @@ | ||
| def testAbsoluteAddition(self): | ||
| self.assertEqual(relativedelta() + relativedelta(day=0, hour=0), | ||
| relativedelta(day=0, hour=0)) | ||
| self.assertEqual(relativedelta(day=0, hour=0) + relativedelta(), | ||
| relativedelta(day=0, hour=0)) | ||
| def testAdditionToDatetime(self): | ||
@@ -421,3 +427,3 @@ self.assertEqual(datetime(2000, 1, 1) + relativedelta(days=1), | ||
| def testRelativeDeltaNormalizeFractionalDays(self): | ||
| def testRelativeDeltaNormalizeFractionalDays2(self): | ||
| # Equivalent to (hours=1, minutes=30) | ||
@@ -453,3 +459,3 @@ rd1 = relativedelta(hours=1.5) | ||
| def testRelativeDeltaFractionalPositiveOverflow(self): | ||
| def testRelativeDeltaFractionalPositiveOverflow2(self): | ||
| # Equivalent to (days=1, hours=14) | ||
@@ -456,0 +462,0 @@ rd1 = relativedelta(days=1.5, hours=2) |
| from .tz import * | ||
| __all__ = ["tzutc", "tzoffset", "tzlocal", "tzfile", "tzrange", | ||
| "tzstr", "tzical", "tzwin", "tzwinlocal", "gettz"] | ||
| "tzstr", "tzical", "tzwin", "tzwinlocal", "gettz", | ||
| "enfold", "datetime_ambiguous", "datetime_exists"] |
+39
-25
| from six import PY3 | ||
| from six.moves import _thread | ||
| from functools import wraps | ||
| from datetime import datetime, timedelta, tzinfo | ||
| import copy | ||
| ZERO = timedelta(0) | ||
@@ -48,3 +49,3 @@ | ||
| ..versionadded:: 2.6.0 | ||
| .. versionadded:: 2.6.0 | ||
| """ | ||
@@ -60,3 +61,3 @@ return dt.replace(fold=fold) | ||
| ..versionadded:: 2.6.0 | ||
| .. versionadded:: 2.6.0 | ||
| """ | ||
@@ -85,3 +86,3 @@ __slots__ = () | ||
| ..versionadded:: 2.6.0 | ||
| .. versionadded:: 2.6.0 | ||
| """ | ||
@@ -100,2 +101,19 @@ if getattr(dt, 'fold', 0) == fold: | ||
| def _validate_fromutc_inputs(f): | ||
| """ | ||
| The CPython version of ``fromutc`` checks that the input is a ``datetime`` | ||
| object and that ``self`` is attached as its ``tzinfo``. | ||
| """ | ||
| @wraps(f) | ||
| def fromutc(self, dt): | ||
| if not isinstance(dt, datetime): | ||
| raise TypeError("fromutc() requires a datetime argument") | ||
| if dt.tzinfo is not self: | ||
| raise ValueError("dt.tzinfo is not self") | ||
| return f(self, dt) | ||
| return fromutc | ||
| class _tzinfo(tzinfo): | ||
@@ -118,3 +136,3 @@ """ | ||
| ..versionadded:: 2.6.0 | ||
| .. versionadded:: 2.6.0 | ||
| """ | ||
@@ -129,3 +147,3 @@ | ||
| same_dt = wall_0.replace(tzinfo=None) == wall_1.replace(tzinfo=None) | ||
| return same_dt and not same_offset | ||
@@ -172,11 +190,6 @@ | ||
| :param dt: | ||
| A timezone-aware :class:`datetime.dateime` object. | ||
| A timezone-aware :class:`datetime.datetime` object. | ||
| """ | ||
| # Re-implement the algorithm from Python's datetime.py | ||
| if not isinstance(dt, datetime): | ||
| raise TypeError("fromutc() requires a datetime argument") | ||
| if dt.tzinfo is not self: | ||
| raise ValueError("dt.tzinfo is not self") | ||
| dtoff = dt.utcoffset() | ||
@@ -194,12 +207,13 @@ if dtoff is None: | ||
| delta = dtoff - dtdst | ||
| if delta: | ||
| dt += delta | ||
| # Set fold=1 so we can default to being in the fold for | ||
| # ambiguous dates. | ||
| dtdst = enfold(dt, fold=1).dst() | ||
| if dtdst is None: | ||
| raise ValueError("fromutc(): dt.dst gave inconsistent " | ||
| "results; cannot convert") | ||
| dt += delta | ||
| # Set fold=1 so we can default to being in the fold for | ||
| # ambiguous dates. | ||
| dtdst = enfold(dt, fold=1).dst() | ||
| if dtdst is None: | ||
| raise ValueError("fromutc(): dt.dst gave inconsistent " | ||
| "results; cannot convert") | ||
| return dt + dtdst | ||
| @_validate_fromutc_inputs | ||
| def fromutc(self, dt): | ||
@@ -216,3 +230,3 @@ """ | ||
| :param dt: | ||
| A timezone-aware :class:`datetime.dateime` object. | ||
| A timezone-aware :class:`datetime.datetime` object. | ||
| """ | ||
@@ -248,3 +262,3 @@ dt_wall = self._fromutc(dt) | ||
| ..versionadded:: 2.6.0 | ||
| .. versionadded:: 2.6.0 | ||
| """ | ||
@@ -303,3 +317,2 @@ def __init__(self): | ||
| isdst = self._naive_isdst(dt_utc, utc_transitions) | ||
@@ -374,3 +387,3 @@ | ||
| return self._dst_offset - self._std_offset | ||
| __hash__ = None | ||
@@ -392,2 +405,3 @@ | ||
| _total_seconds = getattr(timedelta, 'total_seconds', _total_seconds) |
+81
-34
@@ -16,11 +16,7 @@ # -*- coding: utf-8 -*- | ||
| import bisect | ||
| import copy | ||
| from operator import itemgetter | ||
| from contextlib import contextmanager | ||
| from six import string_types, PY3 | ||
| from six import string_types | ||
| from ._common import tzname_in_python2, _tzinfo, _total_seconds | ||
| from ._common import tzrangebase, enfold | ||
| from ._common import _validate_fromutc_inputs | ||
@@ -36,2 +32,3 @@ try: | ||
| class tzutc(datetime.tzinfo): | ||
@@ -67,2 +64,10 @@ """ | ||
| @_validate_fromutc_inputs | ||
| def fromutc(self, dt): | ||
| """ | ||
| Fast track version of fromutc() returns the original ``dt`` object for | ||
| any valid :py:class:`datetime.datetime` object. | ||
| """ | ||
| return dt | ||
| def __eq__(self, other): | ||
@@ -99,3 +104,3 @@ if not isinstance(other, (tzutc, tzoffset)): | ||
| self._name = name | ||
| try: | ||
@@ -114,2 +119,10 @@ # Allow a timedelta | ||
| @tzname_in_python2 | ||
| def tzname(self, dt): | ||
| return self._name | ||
| @_validate_fromutc_inputs | ||
| def fromutc(self, dt): | ||
| return dt + self._offset | ||
| def is_ambiguous(self, dt): | ||
@@ -131,6 +144,2 @@ """ | ||
| @tzname_in_python2 | ||
| def tzname(self, dt): | ||
| return self._name | ||
| def __eq__(self, other): | ||
@@ -323,3 +332,3 @@ if not isinstance(other, tzoffset): | ||
| """ | ||
| attrs = ['trans_list', 'trans_idx', 'ttinfo_list', | ||
| attrs = ['trans_list', 'trans_list_utc', 'trans_idx', 'ttinfo_list', | ||
| 'ttinfo_std', 'ttinfo_dst', 'ttinfo_before', 'ttinfo_first'] | ||
@@ -334,3 +343,3 @@ | ||
| """ | ||
| This is a ``tzinfo`` subclass that allows one to use the ``tzfile(5)`` | ||
| This is a ``tzinfo`` subclass thant allows one to use the ``tzfile(5)`` | ||
| format timezone files to extract current and historical zone information. | ||
@@ -348,3 +357,3 @@ | ||
| See `Sources for Time Zone and Daylight Saving Time Data | ||
| See `Sources for Time Zone and Daylight Saving Time Data | ||
| <http://www.twinsun.com/tz/tz-link.htm>`_ for more information. Time zone | ||
@@ -436,6 +445,6 @@ files can be compiled from the `IANA Time Zone database files | ||
| if timecnt: | ||
| out.trans_list = list(struct.unpack(">%dl" % timecnt, | ||
| fileobj.read(timecnt*4))) | ||
| out.trans_list_utc = list(struct.unpack(">%dl" % timecnt, | ||
| fileobj.read(timecnt*4))) | ||
| else: | ||
| out.trans_list = [] | ||
| out.trans_list_utc = [] | ||
@@ -482,6 +491,5 @@ # Next come tzh_timecnt one-byte values of type unsigned | ||
| # Not used, for now (but read anyway for correct file position) | ||
| # Not used, for now (but seek for correct file position) | ||
| if leapcnt: | ||
| leap = struct.unpack(">%dl" % (leapcnt*2), | ||
| fileobj.read(leapcnt*8)) | ||
| fileobj.seek(leapcnt * 8, os.SEEK_CUR) | ||
@@ -541,3 +549,3 @@ # Then there are tzh_ttisstdcnt standard/wall | ||
| if out.ttinfo_list: | ||
| if not out.trans_list: | ||
| if not out.trans_list_utc: | ||
| out.ttinfo_std = out.ttinfo_first = out.ttinfo_list[0] | ||
@@ -573,2 +581,3 @@ else: | ||
| laststdoffset = None | ||
| out.trans_list = [] | ||
| for i, tti in enumerate(out.trans_idx): | ||
@@ -586,3 +595,3 @@ if not tti.isdst: | ||
| out.trans_list[i] += offset | ||
| out.trans_list.append(out.trans_list_utc[i] + offset) | ||
@@ -602,3 +611,3 @@ # In case we missed any DST offsets on the way in for some reason, make | ||
| tti.dstoffset = datetime.timedelta(seconds=tti.dstoffset) | ||
| out.trans_idx[i] = tti | ||
@@ -608,6 +617,7 @@ | ||
| out.trans_list = tuple(out.trans_list) | ||
| out.trans_list_utc = tuple(out.trans_list_utc) | ||
| return out | ||
| def _find_last_transition(self, dt): | ||
| def _find_last_transition(self, dt, in_utc=False): | ||
| # If there's no list, there are no transitions to find | ||
@@ -621,10 +631,11 @@ if not self._trans_list: | ||
| # timestamp is a transition time, it's part of the "after" period. | ||
| idx = bisect.bisect_right(self._trans_list, timestamp) | ||
| trans_list = self._trans_list_utc if in_utc else self._trans_list | ||
| idx = bisect.bisect_right(trans_list, timestamp) | ||
| # We want to know when the previous transition was, so subtract off 1 | ||
| return idx - 1 | ||
| return idx - 1 | ||
| def _get_ttinfo(self, idx): | ||
| # For no list or after the last transition, default to _ttinfo_std | ||
| if idx is None or (idx + 1) == len(self._trans_list): | ||
| if idx is None or (idx + 1) >= len(self._trans_list): | ||
| return self._ttinfo_std | ||
@@ -643,2 +654,38 @@ | ||
| def fromutc(self, dt): | ||
| """ | ||
| The ``tzfile`` implementation of :py:func:`datetime.tzinfo.fromutc`. | ||
| :param dt: | ||
| A :py:class:`datetime.datetime` object. | ||
| :raises TypeError: | ||
| Raised if ``dt`` is not a :py:class:`datetime.datetime` object. | ||
| :raises ValueError: | ||
| Raised if this is called with a ``dt`` which does not have this | ||
| ``tzinfo`` attached. | ||
| :return: | ||
| Returns a :py:class:`datetime.datetime` object representing the | ||
| wall time in ``self``'s time zone. | ||
| """ | ||
| # These isinstance checks are in datetime.tzinfo, so we'll preserve | ||
| # them, even if we don't care about duck typing. | ||
| if not isinstance(dt, datetime.datetime): | ||
| raise TypeError("fromutc() requires a datetime argument") | ||
| if dt.tzinfo is not self: | ||
| raise ValueError("dt.tzinfo is not self") | ||
| # First treat UTC as wall time and get the transition we're in. | ||
| idx = self._find_last_transition(dt, in_utc=True) | ||
| tti = self._get_ttinfo(idx) | ||
| dt_out = dt + datetime.timedelta(seconds=tti.offset) | ||
| fold = self.is_ambiguous(dt_out, idx=idx) | ||
| return enfold(dt_out, fold=int(fold)) | ||
| def is_ambiguous(self, dt, idx=None): | ||
@@ -681,3 +728,3 @@ """ | ||
| # Get the current datetime as a timestamp | ||
| # If it's ambiguous and we're in a fold, shift to a different index. | ||
| idx_offset = int(not _fold and self.is_ambiguous(dt, idx)) | ||
@@ -702,3 +749,3 @@ | ||
| return ZERO | ||
| tti = self._find_ttinfo(dt) | ||
@@ -1039,3 +1086,2 @@ | ||
| lastcompdt = None | ||
@@ -1122,3 +1168,2 @@ lastcomp = None | ||
| fileobj = open(fileobj, 'r') | ||
| file_opened_here = True | ||
| else: | ||
@@ -1303,2 +1348,3 @@ self._s = getattr(fileobj, 'name', repr(fileobj)) | ||
| if sys.platform != "win32": | ||
@@ -1401,3 +1447,3 @@ TZFILES = ["/etc/localtime", "localtime"] | ||
| ``None`` or not provided, the datetime's own time zone will be used. | ||
| :return: | ||
@@ -1434,3 +1480,3 @@ Returns a boolean value whether or not the "wall time" exists in ``tz``. | ||
| ``None`` or not provided, the datetime's own time zone will be used. | ||
| :return: | ||
@@ -1475,5 +1521,6 @@ Returns a boolean value whether or not the "wall time" is ambiguous in | ||
| class _ContextWrapper(object): | ||
| """ | ||
| Class for wrapping contexts so that they are passed through in a | ||
| Class for wrapping contexts so that they are passed through in a | ||
| with statement. | ||
@@ -1480,0 +1527,0 @@ """ |
@@ -15,3 +15,2 @@ # This code was originally contributed by Jeffrey Harris. | ||
| from ._common import tzname_in_python2, _tzinfo | ||
| from ._common import tzrangebase | ||
@@ -38,2 +37,3 @@ | ||
| TZKEYNAME = _settzkeyname() | ||
@@ -54,3 +54,3 @@ | ||
| user32 = ctypes.WinDLL('user32') | ||
| # Specify the LoadStringW function | ||
@@ -69,3 +69,3 @@ user32.LoadStringW.argtypes = (wintypes.HINSTANCE, | ||
| Load a timezone name from a DLL offset (integer). | ||
| >>> from dateutil.tzwin import tzres | ||
@@ -201,3 +201,3 @@ >>> tzr = tzres() | ||
| with winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE) as handle: | ||
| tzkeyname = text_type("{kn}\{name}").format(kn=TZKEYNAME, name=name) | ||
| tzkeyname = text_type("{kn}\\{name}").format(kn=TZKEYNAME, name=name) | ||
| with winreg.OpenKey(handle, tzkeyname) as tzkey: | ||
@@ -252,3 +252,3 @@ keydict = valuestodict(tzkey) | ||
| try: | ||
| tzkeyname = text_type('{kn}\{sn}').format(kn=TZKEYNAME, | ||
| tzkeyname = text_type('{kn}\\{sn}').format(kn=TZKEYNAME, | ||
| sn=self._std_abbr) | ||
@@ -275,3 +275,3 @@ with winreg.OpenKey(handle, tzkeyname) as tzkey: | ||
| self._stdminute) = tup[1:5] | ||
| self._stddayofweek = tup[7] | ||
@@ -278,0 +278,0 @@ |
| # tzwin has moved to dateutil.tz.win | ||
| from .tz.win import * | ||
| from .tz.win import * |
| # -*- coding: utf-8 -*- | ||
| import logging | ||
| import os | ||
| import warnings | ||
| import tempfile | ||
| import shutil | ||
| import json | ||
@@ -78,3 +74,3 @@ | ||
| for retrieving zones from the zone dictionary. | ||
| :param name: | ||
@@ -100,2 +96,3 @@ The name of the zone to retrieve. (Generally IANA zone names) | ||
| def get_zonefile_instance(new_instance=False): | ||
@@ -129,2 +126,3 @@ """ | ||
| def gettz(name): | ||
@@ -189,3 +187,1 @@ """ | ||
| return _CLASS_ZONE_INSTANCE[0].metadata | ||
@@ -41,2 +41,3 @@ import logging | ||
| def _print_on_nosuchfile(e): | ||
@@ -43,0 +44,0 @@ """Print helpful troubleshooting message |
+2
-1
@@ -5,3 +5,4 @@ dateutil - Extensions to the standard Python datetime module. | ||
| Copyright (c) 2012-2014 - Tomi Pieviläinen <tomi.pievilainen@iki.fi> | ||
| Copyright (c) 2014 - Yaron de Leeuw <me@jarondl.net> | ||
| Copyright (c) 2014-2016 - Yaron de Leeuw <me@jarondl.net> | ||
| Copyright (c) 2015- - Paul Ganssle <paul@ganssle.io> | ||
@@ -8,0 +9,0 @@ All rights reserved. |
+33
-1
@@ -0,1 +1,33 @@ | ||
| Version 2.6.1 | ||
| ------------- | ||
| - Updated zoneinfo file to 2017b. (gh pr #395) | ||
| - Added Python 3.6 to CI testing (gh pr #365) | ||
| - Removed duplicate test name that was preventing a test from being run. | ||
| Reported and fixed by @jdufresne (gh pr #371) | ||
| - Fixed testing of folds and gaps, particularly on Windows (gh pr #392) | ||
| - Fixed deprecated escape characters in regular expressions. Reported by | ||
| @nascheme and @thierryba (gh issue #361), fixed by @thierryba (gh pr #358) | ||
| - Many PEP8 style violations and other code smells were fixed by @jdufresne | ||
| (gh prs #358, #363, #364, #366, #367, #368, #372, #374, #379, #380, #398) | ||
| - Improved performance of tzutc and tzoffset objects. (gh pr #391) | ||
| - Fixed issue with several time zone classes around DST transitions in any | ||
| zones with +0 standard offset (e.g. Europe/London) (gh issue #321, pr #390) | ||
| - Fixed issue with fuzzy parsing where tokens similar to AM/PM that are in the | ||
| end skipped were dropped in the fuzzy_with_tokens list. Reported and fixed | ||
| by @jbrockmendel (gh pr #332). | ||
| - Fixed issue with parsing dates of the form X m YY. Reported by @jbrockmendel. | ||
| (gh issue #333, pr #393) | ||
| - Added support for parser weekdays with less than 3 characters. Reported by | ||
| @arcadefoam (gh issue #343), fixed by @jonemo (gh pr #382) | ||
| - Fixed issue with the addition and subtraction of certain relativedeltas. | ||
| Reported and fixed by @kootenpv (gh issue #346, pr #347) | ||
| - Fixed issue where the COUNT parameter of rrules was ignored if 0. Fixed by | ||
| @mshenfield (gh pr #330), reported by @vaultah (gh issue #329). | ||
| - Updated documentation to include the new tz methods. (gh pr #324) | ||
| - Update documentation to reflect that the parser can raise TypeError, reported | ||
| and fixed by @tomchuk (gh issue #336, pr #337) | ||
| - Fixed an incorrect year in a parser doctest. Fixed by @xlotlu (gh pr #357) | ||
| - Moved version information into _version.py and set up the versions more | ||
| granularly. | ||
| Version 2.6.0 | ||
@@ -48,3 +80,3 @@ ------------- | ||
| - Several classes have been marked as explicitly unhashable to maintain | ||
| identical behavior between Python 2 and 3. Submitted by Roy Williams | ||
| identical behavior between Python 2 and 3. Submitted by Roy Williams | ||
| (@rowillia) (gh pr #296) | ||
@@ -51,0 +83,0 @@ - Trailing whitespace in easter.py has been removed. Submitted by @OmgImAlexis |
+2
-2
| Metadata-Version: 1.1 | ||
| Name: python-dateutil | ||
| Version: 2.6.0 | ||
| Version: 2.6.1 | ||
| Summary: Extensions to the standard Python datetime module | ||
| Home-page: https://dateutil.readthedocs.io | ||
| Author: Paul Ganssle, Yaron de Leeuw | ||
| Author: Paul Ganssle | ||
| Author-email: dateutil@python.org | ||
@@ -8,0 +8,0 @@ License: Simplified BSD |
| Metadata-Version: 1.1 | ||
| Name: python-dateutil | ||
| Version: 2.6.0 | ||
| Version: 2.6.1 | ||
| Summary: Extensions to the standard Python datetime module | ||
| Home-page: https://dateutil.readthedocs.io | ||
| Author: Paul Ganssle, Yaron de Leeuw | ||
| Author: Paul Ganssle | ||
| Author-email: dateutil@python.org | ||
@@ -8,0 +8,0 @@ License: Simplified BSD |
@@ -1,4 +0,1 @@ | ||
| .gitattributes | ||
| .gitignore | ||
| .travis.yml | ||
| LICENSE | ||
@@ -8,15 +5,9 @@ MANIFEST.in | ||
| README.rst | ||
| RELEASING | ||
| appveyor.yml | ||
| codecov.yml | ||
| setup.cfg | ||
| setup.py | ||
| tox.ini | ||
| updatezinfo.py | ||
| zonefile_metadata.json | ||
| ci_tools/pypy_upgrade.sh | ||
| ci_tools/retry.bat | ||
| ci_tools/retry.sh | ||
| dateutil/__init__.py | ||
| dateutil/_common.py | ||
| dateutil/_version.py | ||
| dateutil/easter.py | ||
@@ -42,14 +33,2 @@ dateutil/parser.py | ||
| dateutil/zoneinfo/rebuild.py | ||
| docs/Makefile | ||
| docs/conf.py | ||
| docs/easter.rst | ||
| docs/examples.rst | ||
| docs/index.rst | ||
| docs/make.bat | ||
| docs/parser.rst | ||
| docs/relativedelta.rst | ||
| docs/rrule.rst | ||
| docs/tz.rst | ||
| docs/zoneinfo.rst | ||
| docs/samples/EST5EDT.ics | ||
| python_dateutil.egg-info/PKG-INFO | ||
@@ -56,0 +35,0 @@ python_dateutil.egg-info/SOURCES.txt |
+3
-3
@@ -106,6 +106,6 @@ dateutil - powerful extensions to datetime | ||
| * Tomi Pieviläinen <tomi.pievilainen@iki.fi> 2012-2014 | ||
| * Yaron de Leeuw <me@jarondl.net> 2014- | ||
| * Yaron de Leeuw <me@jarondl.net> 2014-2016 | ||
| * Paul Ganssle <paul@ganssle.io> 2015- | ||
| Our mailing list is available at `dateutil@python.org <https://mail.python.org/mailman/listinfo/dateutil>`_. As it is hosted by the PSF, it is subject to the `PSF code of | ||
| Our mailing list is available at `dateutil@python.org <https://mail.python.org/mailman/listinfo/dateutil>`_. As it is hosted by the PSF, it is subject to the `PSF code of | ||
| conduct <https://www.python.org/psf/codeofconduct/>`_. | ||
@@ -144,2 +144,2 @@ | ||
| .. _6B49 ACBA DCF6 BD1C A206 67AB CD54 FCE3 D964 BEFB: | ||
| https://pgp.mit.edu/pks/lookup?op=vindex&search=0xCD54FCE3D964BEFB | ||
| https://pgp.mit.edu/pks/lookup?op=vindex&search=0xCD54FCE3D964BEFB |
+0
-1
@@ -7,3 +7,2 @@ [bdist_wheel] | ||
| tag_date = 0 | ||
| tag_svn_revision = 0 | ||
+2
-8
@@ -9,2 +9,3 @@ #!/usr/bin/python | ||
| from dateutil._version import VERSION | ||
@@ -14,13 +15,6 @@ if isfile("MANIFEST"): | ||
| TOPDIR = os.path.dirname(__file__) or "." | ||
| VERSION = re.search('__version__ = "([^"]+)"', | ||
| codecs.open(TOPDIR + "/dateutil/__init__.py", | ||
| encoding='utf-8').read()).group(1) | ||
| setup(name="python-dateutil", | ||
| version=VERSION, | ||
| description="Extensions to the standard Python datetime module", | ||
| author="Paul Ganssle, Yaron de Leeuw", | ||
| author="Paul Ganssle", | ||
| author_email="dateutil@python.org", | ||
@@ -27,0 +21,0 @@ url="https://dateutil.readthedocs.io", |
+1
-0
@@ -53,3 +53,4 @@ #!/usr/bin/env python | ||
| if __name__ == "__main__": | ||
| main() |
@@ -7,5 +7,5 @@ { | ||
| ], | ||
| "tzdata_file": "tzdata2016i.tar.gz", | ||
| "tzdata_file_sha512": "801059f43c91798cf69fb2ae77c1ffab8d06987325081511d573febde19ae423e7432c2b65c7c256077bbdb1b359e010302955786e18f2697bb263c4e0f1cc91", | ||
| "tzversion": "2016i", | ||
| "tzdata_file": "tzdata2017b.tar.gz", | ||
| "tzdata_file_sha512": "3e090dba1f52e4c63b4930b28f4bf38b56aabd6728f23094cb5801d10f4e464f17231f17b75b8866714bf98199c166ea840de0787b75b2274aa419a4e14bbc4d", | ||
| "tzversion": "2017b", | ||
| "zonegroups": [ | ||
@@ -12,0 +12,0 @@ "africa", |
| # Set the default behavior, in case people don't have core.autocrlf set. | ||
| * text=auto | ||
| # Specify what's text and should be normalized | ||
| *.py text | ||
| *.in text | ||
| *.rst text | ||
| *.cfg text | ||
| *.ini text | ||
| *.yml text | ||
| *.json text | ||
| *.bat text | ||
| *.sh text | ||
| RELEASING text | ||
| # NEWS and Windows batch files should be crlf | ||
| NEWS eol=crlf | ||
| *.bat eol=crlf |
-14
| # Byte-compiled / optimized / DLL files | ||
| __pycache__/ | ||
| *.py[cod] | ||
| build/ | ||
| dist/ | ||
| *.egg-info/ | ||
| .tox/ | ||
| # Sphinx documentation | ||
| docs/_build/ | ||
| # Timezone information | ||
| tzdata*.tar.gz |
-50
| language: python | ||
| python: | ||
| - "2.6" | ||
| - "2.7" | ||
| - "3.2" | ||
| - "3.3" | ||
| - "3.4" | ||
| - "3.5" | ||
| - "3.6-dev" | ||
| - "nightly" | ||
| - "pypy" | ||
| - "pypy3" | ||
| matrix: | ||
| # pypy3 latest version is not playing nice. | ||
| allow_failures: | ||
| - python: "pypy3" | ||
| - python: "3.6-dev" | ||
| - python: "nightly" | ||
| before_install: | ||
| # Travis version of Pypy is old and is causing some jobs to fail, so | ||
| # we should build this ourselves | ||
| - "export PYENV_ROOT=$HOME/.pyenv" | ||
| - | | ||
| if [ "$TRAVIS_PYTHON_VERSION" = "pypy" ]; then | ||
| export PYPY_VERSION="5.4.1" | ||
| source ./ci_tools/pypy_upgrade.sh | ||
| fi | ||
| # Install codecov | ||
| - if [[ $TRAVIS_PYTHON_VERSION == '3.2' ]]; then pip install coverage==3.7.1; fi | ||
| - pip install codecov | ||
| install: | ||
| - pip install six | ||
| - if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then pip install unittest2; fi | ||
| - ./ci_tools/retry.sh python updatezinfo.py | ||
| cache: | ||
| directories: | ||
| - $HOME/.pyenv | ||
| - $HOME/.cache/pip | ||
| script: | ||
| - coverage run --omit=setup.py,dateutil/test/* setup.py test | ||
| after_success: | ||
| - codecov | ||
| sudo: false |
-35
| build: false | ||
| environment: | ||
| matrix: | ||
| - PYTHON: "C:/Python27" | ||
| - PYTHON: "C:/Python27-x64" | ||
| - PYTHON: "C:/Python33" | ||
| - PYTHON: "C:/Python33-x64" | ||
| - PYTHON: "C:/Python34" | ||
| - PYTHON: "C:/Python34-x64" | ||
| - PYTHON: "C:/Python35" | ||
| - PYTHON: "C:/Python35-x64" | ||
| install: | ||
| # Add PostgreSQL (zic), Python and scripts directory to current path | ||
| - set path=c:\Program Files\PostgreSQL\9.3\bin\;%PATH% | ||
| - set path=%PATH%;%PYTHON%;%PYTHON%/Scripts | ||
| # If this isn't done, I guess Appveyor will install to the Python2.7 version | ||
| - set pip_cmd=%PYTHON%/python.exe -m pip | ||
| # Download scripts and dependencies | ||
| - ps: Start-FileDownload 'https://bootstrap.pypa.io/get-pip.py' | ||
| - "%PYTHON%/python.exe get-pip.py" | ||
| - "%pip_cmd% install six" | ||
| - "%pip_cmd% install coverage" | ||
| - "%pip_cmd% install codecov" | ||
| # This frequently fails with network errors, so we'll retry it up to 5 times | ||
| # with a 1 minute rate limit. | ||
| - "ci_tools/retry.bat %PYTHON%/python.exe updatezinfo.py" | ||
| # This environment variable tells the test suite it's OK to mess with the time zone. | ||
| - set DATEUTIL_MAY_CHANGE_TZ=1 | ||
| test_script: | ||
| - "coverage run --omit=setup.py,dateutil/test/* setup.py test" | ||
| after_test: | ||
| - "codecov" |
| #!/usr/bin/env bash | ||
| # Need to install an upgraded version of pypy. | ||
| if [ -f "$PYENV_ROOT/bin/pyenv" ]; then | ||
| pushd "$PYENV_ROOT" && git pull && popd | ||
| else | ||
| rm -rf "$PYENV_ROOT" && git clone --depth 1 https://github.com/yyuu/pyenv.git "$PYENV_ROOT" | ||
| fi | ||
| "$PYENV_ROOT/bin/pyenv" install --skip-existing "pypy-$PYPY_VERSION" | ||
| virtualenv --python="$PYENV_ROOT/versions/pypy-$PYPY_VERSION/bin/python" "$HOME/virtualenvs/pypy-$PYPY_VERSION" | ||
| source "$HOME/virtualenvs/pypy-$PYPY_VERSION/bin/activate" |
| @echo off | ||
| REM This script takes a command and retries it a few times if it fails, with a | ||
| REM timeout between each retry. | ||
| setlocal EnableDelayedExpansion | ||
| REM Loop at most n_retries times, waiting sleep_time times between | ||
| set sleep_time=60 | ||
| set n_retries=5 | ||
| for /l %%x in (1, 1, %n_retries%) do ( | ||
| call %* | ||
| if not ERRORLEVEL 1 EXIT /B 0 | ||
| timeout /t %sleep_time% /nobreak > nul | ||
| ) | ||
| REM If it failed all n_retries times, we can give up at last. | ||
| EXIT /B 1 |
| #!/usr/bin/env bash | ||
| sleep_time=60 | ||
| n_retries=5 | ||
| for i in `seq 1 $n_retries`; do | ||
| "$@" && exit 0 | ||
| sleep $sleep_time | ||
| done | ||
| exit 1 |
| coverage: | ||
| status: | ||
| patch: false | ||
| changes: false | ||
| project: | ||
| default: | ||
| target: '80' | ||
| comment: false |
-266
| #!/usr/bin/env python3 | ||
| # -*- coding: utf-8 -*- | ||
| # | ||
| # dateutil documentation build configuration file, created by | ||
| # sphinx-quickstart on Thu Nov 20 23:18:41 2014. | ||
| # | ||
| # This file is execfile()d with the current directory set to its | ||
| # containing dir. | ||
| # | ||
| # Note that not all possible configuration values are present in this | ||
| # autogenerated file. | ||
| # | ||
| # All configuration values have a default; values that are commented out | ||
| # serve to show the default. | ||
| import sys | ||
| import os | ||
| # If extensions (or modules to document with autodoc) are in another directory, | ||
| # add these directories to sys.path here. If the directory is relative to the | ||
| # documentation root, use os.path.abspath to make it absolute, like shown here. | ||
| #sys.path.insert(0, os.path.abspath('.')) | ||
| sys.path.insert(0, os.path.abspath('../')) | ||
| # -- General configuration ------------------------------------------------ | ||
| # If your documentation needs a minimal Sphinx version, state it here. | ||
| #needs_sphinx = '1.0' | ||
| # Add any Sphinx extension module names here, as strings. They can be | ||
| # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom | ||
| # ones. | ||
| extensions = [ | ||
| 'sphinx.ext.autodoc', | ||
| 'sphinx.ext.doctest', | ||
| 'sphinx.ext.viewcode', | ||
| ] | ||
| # Add any paths that contain templates here, relative to this directory. | ||
| templates_path = ['_templates'] | ||
| # The suffix of source filenames. | ||
| source_suffix = '.rst' | ||
| # The encoding of source files. | ||
| #source_encoding = 'utf-8-sig' | ||
| # The master toctree document. | ||
| master_doc = 'index' | ||
| # General information about the project. | ||
| project = 'dateutil' | ||
| copyright = '2016, dateutil' | ||
| # The version info for the project you're documenting, acts as replacement for | ||
| # |version| and |release|, also used in various other places throughout the | ||
| # built documents. | ||
| # | ||
| # The short X.Y version. | ||
| from dateutil import __version__ as VERSION # Explicitly use a relative path | ||
| version = VERSION | ||
| # The full version, including alpha/beta/rc tags. | ||
| release = VERSION | ||
| # The language for content autogenerated by Sphinx. Refer to documentation | ||
| # for a list of supported languages. | ||
| #language = None | ||
| # There are two options for replacing |today|: either, you set today to some | ||
| # non-false value, then it is used: | ||
| #today = '' | ||
| # Else, today_fmt is used as the format for a strftime call. | ||
| #today_fmt = '%B %d, %Y' | ||
| # List of patterns, relative to source directory, that match files and | ||
| # directories to ignore when looking for source files. | ||
| exclude_patterns = ['_build'] | ||
| # The reST default role (used for this markup: `text`) to use for all | ||
| # documents. | ||
| #default_role = None | ||
| # If true, '()' will be appended to :func: etc. cross-reference text. | ||
| #add_function_parentheses = True | ||
| # If true, the current module name will be prepended to all description | ||
| # unit titles (such as .. function::). | ||
| #add_module_names = True | ||
| # If true, sectionauthor and moduleauthor directives will be shown in the | ||
| # output. They are ignored by default. | ||
| #show_authors = False | ||
| # The name of the Pygments (syntax highlighting) style to use. | ||
| pygments_style = 'sphinx' | ||
| # A list of ignored prefixes for module index sorting. | ||
| #modindex_common_prefix = [] | ||
| # If true, keep warnings as "system message" paragraphs in the built documents. | ||
| #keep_warnings = False | ||
| # -- Options for HTML output ---------------------------------------------- | ||
| # The theme to use for HTML and HTML Help pages. See the documentation for | ||
| # a list of builtin themes. | ||
| html_theme = 'default' | ||
| # Theme options are theme-specific and customize the look and feel of a theme | ||
| # further. For a list of options available for each theme, see the | ||
| # documentation. | ||
| #html_theme_options = {} | ||
| # Add any paths that contain custom themes here, relative to this directory. | ||
| #html_theme_path = [] | ||
| # The name for this set of Sphinx documents. If None, it defaults to | ||
| # "<project> v<release> documentation". | ||
| #html_title = None | ||
| # A shorter title for the navigation bar. Default is the same as html_title. | ||
| #html_short_title = None | ||
| # The name of an image file (relative to this directory) to place at the top | ||
| # of the sidebar. | ||
| #html_logo = None | ||
| # The name of an image file (within the static path) to use as favicon of the | ||
| # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 | ||
| # pixels large. | ||
| #html_favicon = None | ||
| # Add any paths that contain custom static files (such as style sheets) here, | ||
| # relative to this directory. They are copied after the builtin static files, | ||
| # so a file named "default.css" will overwrite the builtin "default.css". | ||
| html_static_path = ['_static'] | ||
| # Add any extra paths that contain custom files (such as robots.txt or | ||
| # .htaccess) here, relative to this directory. These files are copied | ||
| # directly to the root of the documentation. | ||
| #html_extra_path = [] | ||
| # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, | ||
| # using the given strftime format. | ||
| #html_last_updated_fmt = '%b %d, %Y' | ||
| # If true, SmartyPants will be used to convert quotes and dashes to | ||
| # typographically correct entities. | ||
| #html_use_smartypants = True | ||
| # Custom sidebar templates, maps document names to template names. | ||
| #html_sidebars = {} | ||
| # Additional templates that should be rendered to pages, maps page names to | ||
| # template names. | ||
| #html_additional_pages = {} | ||
| # If false, no module index is generated. | ||
| #html_domain_indices = True | ||
| # If false, no index is generated. | ||
| #html_use_index = True | ||
| # If true, the index is split into individual pages for each letter. | ||
| #html_split_index = False | ||
| # If true, links to the reST sources are added to the pages. | ||
| #html_show_sourcelink = True | ||
| # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. | ||
| #html_show_sphinx = True | ||
| # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. | ||
| #html_show_copyright = True | ||
| # If true, an OpenSearch description file will be output, and all pages will | ||
| # contain a <link> tag referring to it. The value of this option must be the | ||
| # base URL from which the finished HTML is served. | ||
| #html_use_opensearch = '' | ||
| # This is the file name suffix for HTML files (e.g. ".xhtml"). | ||
| #html_file_suffix = None | ||
| # Output file base name for HTML help builder. | ||
| htmlhelp_basename = 'dateutildoc' | ||
| # -- Options for LaTeX output --------------------------------------------- | ||
| latex_elements = { | ||
| # The paper size ('letterpaper' or 'a4paper'). | ||
| #'papersize': 'letterpaper', | ||
| # The font size ('10pt', '11pt' or '12pt'). | ||
| #'pointsize': '10pt', | ||
| # Additional stuff for the LaTeX preamble. | ||
| #'preamble': '', | ||
| } | ||
| # Grouping the document tree into LaTeX files. List of tuples | ||
| # (source start file, target name, title, | ||
| # author, documentclass [howto, manual, or own class]). | ||
| latex_documents = [ | ||
| ('index', 'dateutil.tex', 'dateutil Documentation', | ||
| 'dateutil', 'manual'), | ||
| ] | ||
| # The name of an image file (relative to this directory) to place at the top of | ||
| # the title page. | ||
| #latex_logo = None | ||
| # For "manual" documents, if this is true, then toplevel headings are parts, | ||
| # not chapters. | ||
| #latex_use_parts = False | ||
| # If true, show page references after internal links. | ||
| #latex_show_pagerefs = False | ||
| # If true, show URL addresses after external links. | ||
| #latex_show_urls = False | ||
| # Documents to append as an appendix to all manuals. | ||
| #latex_appendices = [] | ||
| # If false, no module index is generated. | ||
| #latex_domain_indices = True | ||
| # -- Options for manual page output --------------------------------------- | ||
| # One entry per manual page. List of tuples | ||
| # (source start file, name, description, authors, manual section). | ||
| man_pages = [ | ||
| ('index', 'dateutil', 'dateutil Documentation', | ||
| ['dateutil'], 1) | ||
| ] | ||
| # If true, show URL addresses after external links. | ||
| #man_show_urls = False | ||
| # -- Options for Texinfo output ------------------------------------------- | ||
| # Grouping the document tree into Texinfo files. List of tuples | ||
| # (source start file, target name, title, author, | ||
| # dir menu entry, description, category) | ||
| texinfo_documents = [ | ||
| ('index', 'dateutil', 'dateutil Documentation', | ||
| 'dateutil', 'dateutil', 'One line description of project.', | ||
| 'Miscellaneous'), | ||
| ] | ||
| # Documents to append as an appendix to all manuals. | ||
| #texinfo_appendices = [] | ||
| # If false, no module index is generated. | ||
| #texinfo_domain_indices = True | ||
| # How to display URL addresses: 'footnote', 'no', or 'inline'. | ||
| #texinfo_show_urls = 'footnote' | ||
| # If true, do not generate a @detailmenu in the "Top" node's menu. | ||
| #texinfo_no_detailmenu = False |
| ====== | ||
| easter | ||
| ====== | ||
| .. automodule:: dateutil.easter | ||
| :members: | ||
| :undoc-members: |
-1471
| dateutil examples | ||
| ================= | ||
| .. contents:: | ||
| relativedelta examples | ||
| ---------------------- | ||
| .. testsetup:: relativedelta | ||
| from datetime import *; from dateutil.relativedelta import * | ||
| import calendar | ||
| NOW = datetime(2003, 9, 17, 20, 54, 47, 282310) | ||
| TODAY = date(2003, 9, 17) | ||
| Let's begin our trip:: | ||
| >>> from datetime import *; from dateutil.relativedelta import * | ||
| >>> import calendar | ||
| Store some values:: | ||
| >>> NOW = datetime.now() | ||
| >>> TODAY = date.today() | ||
| >>> NOW | ||
| datetime.datetime(2003, 9, 17, 20, 54, 47, 282310) | ||
| >>> TODAY | ||
| datetime.date(2003, 9, 17) | ||
| Next month | ||
| .. doctest:: relativedelta | ||
| >>> NOW+relativedelta(months=+1) | ||
| datetime.datetime(2003, 10, 17, 20, 54, 47, 282310) | ||
| Next month, plus one week. | ||
| .. doctest:: relativedelta | ||
| >>> NOW+relativedelta(months=+1, weeks=+1) | ||
| datetime.datetime(2003, 10, 24, 20, 54, 47, 282310) | ||
| Next month, plus one week, at 10am. | ||
| .. doctest:: relativedelta | ||
| >>> TODAY+relativedelta(months=+1, weeks=+1, hour=10) | ||
| datetime.datetime(2003, 10, 24, 10, 0) | ||
| Here is another example using an absolute relativedelta. Notice the use of | ||
| year and month (both singular) which causes the values to be *replaced* in the | ||
| original datetime rather than performing an arithmetic operation on them. | ||
| .. doctest:: relativedelta | ||
| >>> NOW+relativedelta(year=1, month=1) | ||
| datetime.datetime(1, 1, 17, 20, 54, 47, 282310) | ||
| Let's try the other way around. Notice that the | ||
| hour setting we get in the relativedelta is relative, | ||
| since it's a difference, and the weeks parameter | ||
| has gone. | ||
| .. doctest:: relativedelta | ||
| >>> relativedelta(datetime(2003, 10, 24, 10, 0), TODAY) | ||
| relativedelta(months=+1, days=+7, hours=+10) | ||
| One month before one year. | ||
| .. doctest:: relativedelta | ||
| >>> NOW+relativedelta(years=+1, months=-1) | ||
| datetime.datetime(2004, 8, 17, 20, 54, 47, 282310) | ||
| How does it handle months with different numbers of days? | ||
| Notice that adding one month will never cross the month | ||
| boundary. | ||
| .. doctest:: relativedelta | ||
| >>> date(2003,1,27)+relativedelta(months=+1) | ||
| datetime.date(2003, 2, 27) | ||
| >>> date(2003,1,31)+relativedelta(months=+1) | ||
| datetime.date(2003, 2, 28) | ||
| >>> date(2003,1,31)+relativedelta(months=+2) | ||
| datetime.date(2003, 3, 31) | ||
| The logic for years is the same, even on leap years. | ||
| .. doctest:: relativedelta | ||
| >>> date(2000,2,28)+relativedelta(years=+1) | ||
| datetime.date(2001, 2, 28) | ||
| >>> date(2000,2,29)+relativedelta(years=+1) | ||
| datetime.date(2001, 2, 28) | ||
| >>> date(1999,2,28)+relativedelta(years=+1) | ||
| datetime.date(2000, 2, 28) | ||
| >>> date(1999,3,1)+relativedelta(years=+1) | ||
| datetime.date(2000, 3, 1) | ||
| >>> date(2001,2,28)+relativedelta(years=-1) | ||
| datetime.date(2000, 2, 28) | ||
| >>> date(2001,3,1)+relativedelta(years=-1) | ||
| datetime.date(2000, 3, 1) | ||
| Next friday | ||
| .. doctest:: relativedelta | ||
| >>> TODAY+relativedelta(weekday=FR) | ||
| datetime.date(2003, 9, 19) | ||
| >>> TODAY+relativedelta(weekday=calendar.FRIDAY) | ||
| datetime.date(2003, 9, 19) | ||
| Last friday in this month. | ||
| .. doctest:: relativedelta | ||
| >>> TODAY+relativedelta(day=31, weekday=FR(-1)) | ||
| datetime.date(2003, 9, 26) | ||
| Next wednesday (it's today!). | ||
| .. doctest:: relativedelta | ||
| >>> TODAY+relativedelta(weekday=WE(+1)) | ||
| datetime.date(2003, 9, 17) | ||
| Next wednesday, but not today. | ||
| .. doctest:: relativedelta | ||
| >>> TODAY+relativedelta(days=+1, weekday=WE(+1)) | ||
| datetime.date(2003, 9, 24) | ||
| Following | ||
| [http://www.cl.cam.ac.uk/~mgk25/iso-time.html ISO year week number notation] | ||
| find the first day of the 15th week of 1997. | ||
| .. doctest:: relativedelta | ||
| >>> datetime(1997,1,1)+relativedelta(day=4, weekday=MO(-1), weeks=+14) | ||
| datetime.datetime(1997, 4, 7, 0, 0) | ||
| How long ago has the millennium changed? | ||
| .. doctest:: relativedelta | ||
| :options: +NORMALIZE_WHITESPACE | ||
| >>> relativedelta(NOW, date(2001,1,1)) | ||
| relativedelta(years=+2, months=+8, days=+16, | ||
| hours=+20, minutes=+54, seconds=+47, microseconds=+282310) | ||
| How old is John? | ||
| .. doctest:: relativedelta | ||
| :options: +NORMALIZE_WHITESPACE | ||
| >>> johnbirthday = datetime(1978, 4, 5, 12, 0) | ||
| >>> relativedelta(NOW, johnbirthday) | ||
| relativedelta(years=+25, months=+5, days=+12, | ||
| hours=+8, minutes=+54, seconds=+47, microseconds=+282310) | ||
| It works with dates too. | ||
| .. doctest:: relativedelta | ||
| >>> relativedelta(TODAY, johnbirthday) | ||
| relativedelta(years=+25, months=+5, days=+11, hours=+12) | ||
| Obtain today's date using the yearday: | ||
| .. doctest:: relativedelta | ||
| >>> date(2003, 1, 1)+relativedelta(yearday=260) | ||
| datetime.date(2003, 9, 17) | ||
| We can use today's date, since yearday should be absolute | ||
| in the given year: | ||
| .. doctest:: relativedelta | ||
| >>> TODAY+relativedelta(yearday=260) | ||
| datetime.date(2003, 9, 17) | ||
| Last year it should be in the same day: | ||
| .. doctest:: relativedelta | ||
| >>> date(2002, 1, 1)+relativedelta(yearday=260) | ||
| datetime.date(2002, 9, 17) | ||
| But not in a leap year: | ||
| .. doctest:: relativedelta | ||
| >>> date(2000, 1, 1)+relativedelta(yearday=260) | ||
| datetime.date(2000, 9, 16) | ||
| We can use the non-leap year day to ignore this: | ||
| .. doctest:: relativedelta | ||
| >>> date(2000, 1, 1)+relativedelta(nlyearday=260) | ||
| datetime.date(2000, 9, 17) | ||
| rrule examples | ||
| -------------- | ||
| These examples were converted from the RFC. | ||
| Prepare the environment. | ||
| .. testsetup:: rrule | ||
| from dateutil.rrule import * | ||
| from dateutil.parser import * | ||
| from datetime import * | ||
| import pprint | ||
| import sys | ||
| sys.displayhook = pprint.pprint | ||
| .. doctest:: rrule | ||
| >>> from dateutil.rrule import * | ||
| >>> from dateutil.parser import * | ||
| >>> from datetime import * | ||
| >>> import pprint | ||
| >>> import sys | ||
| >>> sys.displayhook = pprint.pprint | ||
| Daily, for 10 occurrences. | ||
| .. doctest:: rrule | ||
| :options: +NORMALIZE_WHITESPACE | ||
| >>> list(rrule(DAILY, count=10, | ||
| ... dtstart=parse("19970902T090000"))) | ||
| [datetime.datetime(1997, 9, 2, 9, 0), | ||
| datetime.datetime(1997, 9, 3, 9, 0), | ||
| datetime.datetime(1997, 9, 4, 9, 0), | ||
| datetime.datetime(1997, 9, 5, 9, 0), | ||
| datetime.datetime(1997, 9, 6, 9, 0), | ||
| datetime.datetime(1997, 9, 7, 9, 0), | ||
| datetime.datetime(1997, 9, 8, 9, 0), | ||
| datetime.datetime(1997, 9, 9, 9, 0), | ||
| datetime.datetime(1997, 9, 10, 9, 0), | ||
| datetime.datetime(1997, 9, 11, 9, 0)] | ||
| Daily until December 24, 1997 | ||
| .. doctest:: rrule | ||
| :options: +NORMALIZE_WHITESPACE, +ELLIPSIS | ||
| >>> list(rrule(DAILY, | ||
| ... dtstart=parse("19970902T090000"), | ||
| ... until=parse("19971224T000000"))) | ||
| [datetime.datetime(1997, 9, 2, 9, 0), | ||
| datetime.datetime(1997, 9, 3, 9, 0), | ||
| datetime.datetime(1997, 9, 4, 9, 0), | ||
| ... | ||
| datetime.datetime(1997, 12, 21, 9, 0), | ||
| datetime.datetime(1997, 12, 22, 9, 0), | ||
| datetime.datetime(1997, 12, 23, 9, 0)] | ||
| Every other day, 5 occurrences. | ||
| .. doctest:: rrule | ||
| :options: +NORMALIZE_WHITESPACE | ||
| >>> list(rrule(DAILY, interval=2, count=5, | ||
| ... dtstart=parse("19970902T090000"))) | ||
| [datetime.datetime(1997, 9, 2, 9, 0), | ||
| datetime.datetime(1997, 9, 4, 9, 0), | ||
| datetime.datetime(1997, 9, 6, 9, 0), | ||
| datetime.datetime(1997, 9, 8, 9, 0), | ||
| datetime.datetime(1997, 9, 10, 9, 0)] | ||
| Every 10 days, 5 occurrences. | ||
| .. doctest:: rrule | ||
| :options: +NORMALIZE_WHITESPACE | ||
| >>> list(rrule(DAILY, interval=10, count=5, | ||
| ... dtstart=parse("19970902T090000"))) | ||
| [datetime.datetime(1997, 9, 2, 9, 0), | ||
| datetime.datetime(1997, 9, 12, 9, 0), | ||
| datetime.datetime(1997, 9, 22, 9, 0), | ||
| datetime.datetime(1997, 10, 2, 9, 0), | ||
| datetime.datetime(1997, 10, 12, 9, 0)] | ||
| Everyday in January, for 3 years. | ||
| .. doctest:: rrule | ||
| :options: +NORMALIZE_WHITESPACE, +ELLIPSIS | ||
| >>> list(rrule(YEARLY, bymonth=1, byweekday=range(7), | ||
| ... dtstart=parse("19980101T090000"), | ||
| ... until=parse("20000131T090000"))) | ||
| [datetime.datetime(1998, 1, 1, 9, 0), | ||
| datetime.datetime(1998, 1, 2, 9, 0), | ||
| ... | ||
| datetime.datetime(1998, 1, 30, 9, 0), | ||
| datetime.datetime(1998, 1, 31, 9, 0), | ||
| datetime.datetime(1999, 1, 1, 9, 0), | ||
| datetime.datetime(1999, 1, 2, 9, 0), | ||
| ... | ||
| datetime.datetime(1999, 1, 30, 9, 0), | ||
| datetime.datetime(1999, 1, 31, 9, 0), | ||
| datetime.datetime(2000, 1, 1, 9, 0), | ||
| datetime.datetime(2000, 1, 2, 9, 0), | ||
| ... | ||
| datetime.datetime(2000, 1, 30, 9, 0), | ||
| datetime.datetime(2000, 1, 31, 9, 0)] | ||
| Same thing, in another way. | ||
| .. doctest:: rrule | ||
| :options: +NORMALIZE_WHITESPACE, +ELLIPSIS | ||
| >>> list(rrule(DAILY, bymonth=1, | ||
| ... dtstart=parse("19980101T090000"), | ||
| ... until=parse("20000131T090000"))) | ||
| [datetime.datetime(1998, 1, 1, 9, 0), | ||
| ... | ||
| datetime.datetime(2000, 1, 31, 9, 0)] | ||
| Weekly for 10 occurrences. | ||
| .. doctest:: rrule | ||
| :options: +NORMALIZE_WHITESPACE | ||
| >>> list(rrule(WEEKLY, count=10, | ||
| ... dtstart=parse("19970902T090000"))) | ||
| [datetime.datetime(1997, 9, 2, 9, 0), | ||
| datetime.datetime(1997, 9, 9, 9, 0), | ||
| datetime.datetime(1997, 9, 16, 9, 0), | ||
| datetime.datetime(1997, 9, 23, 9, 0), | ||
| datetime.datetime(1997, 9, 30, 9, 0), | ||
| datetime.datetime(1997, 10, 7, 9, 0), | ||
| datetime.datetime(1997, 10, 14, 9, 0), | ||
| datetime.datetime(1997, 10, 21, 9, 0), | ||
| datetime.datetime(1997, 10, 28, 9, 0), | ||
| datetime.datetime(1997, 11, 4, 9, 0)] | ||
| Every other week, 6 occurrences. | ||
| .. doctest:: rrule | ||
| :options: +NORMALIZE_WHITESPACE | ||
| >>> list(rrule(WEEKLY, interval=2, count=6, | ||
| ... dtstart=parse("19970902T090000"))) | ||
| [datetime.datetime(1997, 9, 2, 9, 0), | ||
| datetime.datetime(1997, 9, 16, 9, 0), | ||
| datetime.datetime(1997, 9, 30, 9, 0), | ||
| datetime.datetime(1997, 10, 14, 9, 0), | ||
| datetime.datetime(1997, 10, 28, 9, 0), | ||
| datetime.datetime(1997, 11, 11, 9, 0)] | ||
| Weekly on Tuesday and Thursday for 5 weeks. | ||
| .. doctest:: rrule | ||
| :options: +NORMALIZE_WHITESPACE | ||
| >>> list(rrule(WEEKLY, count=10, wkst=SU, byweekday=(TU,TH), | ||
| ... dtstart=parse("19970902T090000"))) | ||
| [datetime.datetime(1997, 9, 2, 9, 0), | ||
| datetime.datetime(1997, 9, 4, 9, 0), | ||
| datetime.datetime(1997, 9, 9, 9, 0), | ||
| datetime.datetime(1997, 9, 11, 9, 0), | ||
| datetime.datetime(1997, 9, 16, 9, 0), | ||
| datetime.datetime(1997, 9, 18, 9, 0), | ||
| datetime.datetime(1997, 9, 23, 9, 0), | ||
| datetime.datetime(1997, 9, 25, 9, 0), | ||
| datetime.datetime(1997, 9, 30, 9, 0), | ||
| datetime.datetime(1997, 10, 2, 9, 0)] | ||
| Every other week on Tuesday and Thursday, for 8 occurrences. | ||
| .. doctest:: rrule | ||
| :options: +NORMALIZE_WHITESPACE | ||
| >>> list(rrule(WEEKLY, interval=2, count=8, | ||
| ... wkst=SU, byweekday=(TU,TH), | ||
| ... dtstart=parse("19970902T090000"))) | ||
| [datetime.datetime(1997, 9, 2, 9, 0), | ||
| datetime.datetime(1997, 9, 4, 9, 0), | ||
| datetime.datetime(1997, 9, 16, 9, 0), | ||
| datetime.datetime(1997, 9, 18, 9, 0), | ||
| datetime.datetime(1997, 9, 30, 9, 0), | ||
| datetime.datetime(1997, 10, 2, 9, 0), | ||
| datetime.datetime(1997, 10, 14, 9, 0), | ||
| datetime.datetime(1997, 10, 16, 9, 0)] | ||
| Monthly on the 1st Friday for ten occurrences. | ||
| .. doctest:: rrule | ||
| :options: +NORMALIZE_WHITESPACE | ||
| >>> list(rrule(MONTHLY, count=10, byweekday=FR(1), | ||
| ... dtstart=parse("19970905T090000"))) | ||
| [datetime.datetime(1997, 9, 5, 9, 0), | ||
| datetime.datetime(1997, 10, 3, 9, 0), | ||
| datetime.datetime(1997, 11, 7, 9, 0), | ||
| datetime.datetime(1997, 12, 5, 9, 0), | ||
| datetime.datetime(1998, 1, 2, 9, 0), | ||
| datetime.datetime(1998, 2, 6, 9, 0), | ||
| datetime.datetime(1998, 3, 6, 9, 0), | ||
| datetime.datetime(1998, 4, 3, 9, 0), | ||
| datetime.datetime(1998, 5, 1, 9, 0), | ||
| datetime.datetime(1998, 6, 5, 9, 0)] | ||
| Every other month on the 1st and last Sunday of the month for 10 occurrences. | ||
| .. doctest:: rrule | ||
| :options: +NORMALIZE_WHITESPACE | ||
| >>> list(rrule(MONTHLY, interval=2, count=10, | ||
| ... byweekday=(SU(1), SU(-1)), | ||
| ... dtstart=parse("19970907T090000"))) | ||
| [datetime.datetime(1997, 9, 7, 9, 0), | ||
| datetime.datetime(1997, 9, 28, 9, 0), | ||
| datetime.datetime(1997, 11, 2, 9, 0), | ||
| datetime.datetime(1997, 11, 30, 9, 0), | ||
| datetime.datetime(1998, 1, 4, 9, 0), | ||
| datetime.datetime(1998, 1, 25, 9, 0), | ||
| datetime.datetime(1998, 3, 1, 9, 0), | ||
| datetime.datetime(1998, 3, 29, 9, 0), | ||
| datetime.datetime(1998, 5, 3, 9, 0), | ||
| datetime.datetime(1998, 5, 31, 9, 0)] | ||
| Monthly on the second to last Monday of the month for 6 months. | ||
| .. doctest:: rrule | ||
| :options: +NORMALIZE_WHITESPACE | ||
| >>> list(rrule(MONTHLY, count=6, byweekday=MO(-2), | ||
| ... dtstart=parse("19970922T090000"))) | ||
| [datetime.datetime(1997, 9, 22, 9, 0), | ||
| datetime.datetime(1997, 10, 20, 9, 0), | ||
| datetime.datetime(1997, 11, 17, 9, 0), | ||
| datetime.datetime(1997, 12, 22, 9, 0), | ||
| datetime.datetime(1998, 1, 19, 9, 0), | ||
| datetime.datetime(1998, 2, 16, 9, 0)] | ||
| Monthly on the third to the last day of the month, for 6 months. | ||
| .. doctest:: rrule | ||
| :options: +NORMALIZE_WHITESPACE | ||
| >>> list(rrule(MONTHLY, count=6, bymonthday=-3, | ||
| ... dtstart=parse("19970928T090000"))) | ||
| [datetime.datetime(1997, 9, 28, 9, 0), | ||
| datetime.datetime(1997, 10, 29, 9, 0), | ||
| datetime.datetime(1997, 11, 28, 9, 0), | ||
| datetime.datetime(1997, 12, 29, 9, 0), | ||
| datetime.datetime(1998, 1, 29, 9, 0), | ||
| datetime.datetime(1998, 2, 26, 9, 0)] | ||
| Monthly on the 2nd and 15th of the month for 5 occurrences. | ||
| .. doctest:: rrule | ||
| :options: +NORMALIZE_WHITESPACE | ||
| >>> list(rrule(MONTHLY, count=5, bymonthday=(2,15), | ||
| ... dtstart=parse("19970902T090000"))) | ||
| [datetime.datetime(1997, 9, 2, 9, 0), | ||
| datetime.datetime(1997, 9, 15, 9, 0), | ||
| datetime.datetime(1997, 10, 2, 9, 0), | ||
| datetime.datetime(1997, 10, 15, 9, 0), | ||
| datetime.datetime(1997, 11, 2, 9, 0)] | ||
| Monthly on the first and last day of the month for 3 occurrences. | ||
| .. doctest:: rrule | ||
| :options: +NORMALIZE_WHITESPACE | ||
| >>> list(rrule(MONTHLY, count=5, bymonthday=(-1,1,), | ||
| ... dtstart=parse("19970902T090000"))) | ||
| [datetime.datetime(1997, 9, 30, 9, 0), | ||
| datetime.datetime(1997, 10, 1, 9, 0), | ||
| datetime.datetime(1997, 10, 31, 9, 0), | ||
| datetime.datetime(1997, 11, 1, 9, 0), | ||
| datetime.datetime(1997, 11, 30, 9, 0)] | ||
| Every 18 months on the 10th thru 15th of the month for 10 occurrences. | ||
| .. doctest:: rrule | ||
| :options: +NORMALIZE_WHITESPACE | ||
| >>> list(rrule(MONTHLY, interval=18, count=10, | ||
| ... bymonthday=range(10,16), | ||
| ... dtstart=parse("19970910T090000"))) | ||
| [datetime.datetime(1997, 9, 10, 9, 0), | ||
| datetime.datetime(1997, 9, 11, 9, 0), | ||
| datetime.datetime(1997, 9, 12, 9, 0), | ||
| datetime.datetime(1997, 9, 13, 9, 0), | ||
| datetime.datetime(1997, 9, 14, 9, 0), | ||
| datetime.datetime(1997, 9, 15, 9, 0), | ||
| datetime.datetime(1999, 3, 10, 9, 0), | ||
| datetime.datetime(1999, 3, 11, 9, 0), | ||
| datetime.datetime(1999, 3, 12, 9, 0), | ||
| datetime.datetime(1999, 3, 13, 9, 0)] | ||
| Every Tuesday, every other month, 6 occurences. | ||
| .. doctest:: rrule | ||
| :options: +NORMALIZE_WHITESPACE | ||
| >>> list(rrule(MONTHLY, interval=2, count=6, byweekday=TU, | ||
| ... dtstart=parse("19970902T090000"))) | ||
| [datetime.datetime(1997, 9, 2, 9, 0), | ||
| datetime.datetime(1997, 9, 9, 9, 0), | ||
| datetime.datetime(1997, 9, 16, 9, 0), | ||
| datetime.datetime(1997, 9, 23, 9, 0), | ||
| datetime.datetime(1997, 9, 30, 9, 0), | ||
| datetime.datetime(1997, 11, 4, 9, 0)] | ||
| Yearly in June and July for 10 occurrences. | ||
| .. doctest:: rrule | ||
| :options: +NORMALIZE_WHITESPACE | ||
| >>> list(rrule(YEARLY, count=4, bymonth=(6,7), | ||
| ... dtstart=parse("19970610T090000"))) | ||
| [datetime.datetime(1997, 6, 10, 9, 0), | ||
| datetime.datetime(1997, 7, 10, 9, 0), | ||
| datetime.datetime(1998, 6, 10, 9, 0), | ||
| datetime.datetime(1998, 7, 10, 9, 0)] | ||
| Every 3rd year on the 1st, 100th and 200th day for 4 occurrences. | ||
| .. doctest:: rrule | ||
| :options: +NORMALIZE_WHITESPACE | ||
| >>> list(rrule(YEARLY, count=4, interval=3, byyearday=(1,100,200), | ||
| ... dtstart=parse("19970101T090000"))) | ||
| [datetime.datetime(1997, 1, 1, 9, 0), | ||
| datetime.datetime(1997, 4, 10, 9, 0), | ||
| datetime.datetime(1997, 7, 19, 9, 0), | ||
| datetime.datetime(2000, 1, 1, 9, 0)] | ||
| Every 20th Monday of the year, 3 occurrences. | ||
| .. doctest:: rrule | ||
| :options: +NORMALIZE_WHITESPACE | ||
| >>> list(rrule(YEARLY, count=3, byweekday=MO(20), | ||
| ... dtstart=parse("19970519T090000"))) | ||
| [datetime.datetime(1997, 5, 19, 9, 0), | ||
| datetime.datetime(1998, 5, 18, 9, 0), | ||
| datetime.datetime(1999, 5, 17, 9, 0)] | ||
| Monday of week number 20 (where the default start of the week is Monday), | ||
| 3 occurrences. | ||
| .. doctest:: rrule | ||
| :options: +NORMALIZE_WHITESPACE | ||
| >>> list(rrule(YEARLY, count=3, byweekno=20, byweekday=MO, | ||
| ... dtstart=parse("19970512T090000"))) | ||
| [datetime.datetime(1997, 5, 12, 9, 0), | ||
| datetime.datetime(1998, 5, 11, 9, 0), | ||
| datetime.datetime(1999, 5, 17, 9, 0)] | ||
| The week number 1 may be in the last year. | ||
| .. doctest:: rrule | ||
| :options: +NORMALIZE_WHITESPACE | ||
| >>> list(rrule(WEEKLY, count=3, byweekno=1, byweekday=MO, | ||
| ... dtstart=parse("19970902T090000"))) | ||
| [datetime.datetime(1997, 12, 29, 9, 0), | ||
| datetime.datetime(1999, 1, 4, 9, 0), | ||
| datetime.datetime(2000, 1, 3, 9, 0)] | ||
| And the week numbers greater than 51 may be in the next year. | ||
| .. doctest:: rrule | ||
| :options: +NORMALIZE_WHITESPACE | ||
| >>> list(rrule(WEEKLY, count=3, byweekno=52, byweekday=SU, | ||
| ... dtstart=parse("19970902T090000"))) | ||
| [datetime.datetime(1997, 12, 28, 9, 0), | ||
| datetime.datetime(1998, 12, 27, 9, 0), | ||
| datetime.datetime(2000, 1, 2, 9, 0)] | ||
| Only some years have week number 53: | ||
| .. doctest:: rrule | ||
| :options: +NORMALIZE_WHITESPACE | ||
| >>> list(rrule(WEEKLY, count=3, byweekno=53, byweekday=MO, | ||
| ... dtstart=parse("19970902T090000"))) | ||
| [datetime.datetime(1998, 12, 28, 9, 0), | ||
| datetime.datetime(2004, 12, 27, 9, 0), | ||
| datetime.datetime(2009, 12, 28, 9, 0)] | ||
| Every Friday the 13th, 4 occurrences. | ||
| .. doctest:: rrule | ||
| :options: +NORMALIZE_WHITESPACE | ||
| >>> list(rrule(YEARLY, count=4, byweekday=FR, bymonthday=13, | ||
| ... dtstart=parse("19970902T090000"))) | ||
| [datetime.datetime(1998, 2, 13, 9, 0), | ||
| datetime.datetime(1998, 3, 13, 9, 0), | ||
| datetime.datetime(1998, 11, 13, 9, 0), | ||
| datetime.datetime(1999, 8, 13, 9, 0)] | ||
| Every four years, the first Tuesday after a Monday in November, | ||
| 3 occurrences (U.S. Presidential Election day): | ||
| .. doctest:: rrule | ||
| :options: +NORMALIZE_WHITESPACE | ||
| >>> list(rrule(YEARLY, interval=4, count=3, bymonth=11, | ||
| ... byweekday=TU, bymonthday=(2,3,4,5,6,7,8), | ||
| ... dtstart=parse("19961105T090000"))) | ||
| [datetime.datetime(1996, 11, 5, 9, 0), | ||
| datetime.datetime(2000, 11, 7, 9, 0), | ||
| datetime.datetime(2004, 11, 2, 9, 0)] | ||
| The 3rd instance into the month of one of Tuesday, Wednesday or | ||
| Thursday, for the next 3 months: | ||
| .. doctest:: rrule | ||
| :options: +NORMALIZE_WHITESPACE | ||
| >>> list(rrule(MONTHLY, count=3, byweekday=(TU,WE,TH), | ||
| ... bysetpos=3, dtstart=parse("19970904T090000"))) | ||
| [datetime.datetime(1997, 9, 4, 9, 0), | ||
| datetime.datetime(1997, 10, 7, 9, 0), | ||
| datetime.datetime(1997, 11, 6, 9, 0)] | ||
| The 2nd to last weekday of the month, 3 occurrences. | ||
| .. doctest:: rrule | ||
| :options: +NORMALIZE_WHITESPACE | ||
| >>> list(rrule(MONTHLY, count=3, byweekday=(MO,TU,WE,TH,FR), | ||
| ... bysetpos=-2, dtstart=parse("19970929T090000"))) | ||
| [datetime.datetime(1997, 9, 29, 9, 0), | ||
| datetime.datetime(1997, 10, 30, 9, 0), | ||
| datetime.datetime(1997, 11, 27, 9, 0)] | ||
| Every 3 hours from 9:00 AM to 5:00 PM on a specific day. | ||
| .. doctest:: rrule | ||
| :options: +NORMALIZE_WHITESPACE | ||
| >>> list(rrule(HOURLY, interval=3, | ||
| ... dtstart=parse("19970902T090000"), | ||
| ... until=parse("19970902T170000"))) | ||
| [datetime.datetime(1997, 9, 2, 9, 0), | ||
| datetime.datetime(1997, 9, 2, 12, 0), | ||
| datetime.datetime(1997, 9, 2, 15, 0)] | ||
| Every 15 minutes for 6 occurrences. | ||
| .. doctest:: rrule | ||
| :options: +NORMALIZE_WHITESPACE | ||
| >>> list(rrule(MINUTELY, interval=15, count=6, | ||
| ... dtstart=parse("19970902T090000"))) | ||
| [datetime.datetime(1997, 9, 2, 9, 0), | ||
| datetime.datetime(1997, 9, 2, 9, 15), | ||
| datetime.datetime(1997, 9, 2, 9, 30), | ||
| datetime.datetime(1997, 9, 2, 9, 45), | ||
| datetime.datetime(1997, 9, 2, 10, 0), | ||
| datetime.datetime(1997, 9, 2, 10, 15)] | ||
| Every hour and a half for 4 occurrences. | ||
| .. doctest:: rrule | ||
| :options: +NORMALIZE_WHITESPACE | ||
| >>> list(rrule(MINUTELY, interval=90, count=4, | ||
| ... dtstart=parse("19970902T090000"))) | ||
| [datetime.datetime(1997, 9, 2, 9, 0), | ||
| datetime.datetime(1997, 9, 2, 10, 30), | ||
| datetime.datetime(1997, 9, 2, 12, 0), | ||
| datetime.datetime(1997, 9, 2, 13, 30)] | ||
| Every 20 minutes from 9:00 AM to 4:40 PM for two days. | ||
| .. doctest:: rrule | ||
| :options: +NORMALIZE_WHITESPACE, +ELLIPSIS | ||
| >>> list(rrule(MINUTELY, interval=20, count=48, | ||
| ... byhour=range(9,17), byminute=(0,20,40), | ||
| ... dtstart=parse("19970902T090000"))) | ||
| [datetime.datetime(1997, 9, 2, 9, 0), | ||
| datetime.datetime(1997, 9, 2, 9, 20), | ||
| ... | ||
| datetime.datetime(1997, 9, 2, 16, 20), | ||
| datetime.datetime(1997, 9, 2, 16, 40), | ||
| datetime.datetime(1997, 9, 3, 9, 0), | ||
| datetime.datetime(1997, 9, 3, 9, 20), | ||
| ... | ||
| datetime.datetime(1997, 9, 3, 16, 20), | ||
| datetime.datetime(1997, 9, 3, 16, 40)] | ||
| An example where the days generated makes a difference because of `wkst`. | ||
| .. doctest:: rrule | ||
| :options: +NORMALIZE_WHITESPACE | ||
| >>> list(rrule(WEEKLY, interval=2, count=4, | ||
| ... byweekday=(TU,SU), wkst=MO, | ||
| ... dtstart=parse("19970805T090000"))) | ||
| [datetime.datetime(1997, 8, 5, 9, 0), | ||
| datetime.datetime(1997, 8, 10, 9, 0), | ||
| datetime.datetime(1997, 8, 19, 9, 0), | ||
| datetime.datetime(1997, 8, 24, 9, 0)] | ||
| >>> list(rrule(WEEKLY, interval=2, count=4, | ||
| ... byweekday=(TU,SU), wkst=SU, | ||
| ... dtstart=parse("19970805T090000"))) | ||
| [datetime.datetime(1997, 8, 5, 9, 0), | ||
| datetime.datetime(1997, 8, 17, 9, 0), | ||
| datetime.datetime(1997, 8, 19, 9, 0), | ||
| datetime.datetime(1997, 8, 31, 9, 0)] | ||
| rruleset examples | ||
| ----------------- | ||
| Daily, for 7 days, jumping Saturday and Sunday occurrences. | ||
| .. testsetup:: rruleset | ||
| import datetime | ||
| from dateutil.parser import parse | ||
| from dateutil.rrule import rrule, rruleset | ||
| from dateutil.rrule import YEARLY, MONTHLY, WEEKLY, DAILY | ||
| from dateutil.rrule import MO, TU, WE, TH, FR, SA, SU | ||
| import pprint | ||
| import sys | ||
| sys.displayhook = pprint.pprint | ||
| .. doctest:: rruleset | ||
| :options: +NORMALIZE_WHITESPACE | ||
| >>> set = rruleset() | ||
| >>> set.rrule(rrule(DAILY, count=7, | ||
| ... dtstart=parse("19970902T090000"))) | ||
| >>> set.exrule(rrule(YEARLY, byweekday=(SA,SU), | ||
| ... dtstart=parse("19970902T090000"))) | ||
| >>> list(set) | ||
| [datetime.datetime(1997, 9, 2, 9, 0), | ||
| datetime.datetime(1997, 9, 3, 9, 0), | ||
| datetime.datetime(1997, 9, 4, 9, 0), | ||
| datetime.datetime(1997, 9, 5, 9, 0), | ||
| datetime.datetime(1997, 9, 8, 9, 0)] | ||
| Weekly, for 4 weeks, plus one time on day 7, and not on day 16. | ||
| .. doctest:: rruleset | ||
| :options: +NORMALIZE_WHITESPACE | ||
| >>> set = rruleset() | ||
| >>> set.rrule(rrule(WEEKLY, count=4, | ||
| ... dtstart=parse("19970902T090000"))) | ||
| >>> set.rdate(datetime.datetime(1997, 9, 7, 9, 0)) | ||
| >>> set.exdate(datetime.datetime(1997, 9, 16, 9, 0)) | ||
| >>> list(set) | ||
| [datetime.datetime(1997, 9, 2, 9, 0), | ||
| datetime.datetime(1997, 9, 7, 9, 0), | ||
| datetime.datetime(1997, 9, 9, 9, 0), | ||
| datetime.datetime(1997, 9, 23, 9, 0)] | ||
| rrulestr() examples | ||
| ------------------- | ||
| Every 10 days, 5 occurrences. | ||
| .. testsetup:: rrulestr | ||
| from dateutil.parser import parse | ||
| from dateutil.rrule import rruleset, rrulestr | ||
| import pprint | ||
| import sys | ||
| sys.displayhook = pprint.pprint | ||
| .. doctest:: rrulestr | ||
| :options: +NORMALIZE_WHITESPACE | ||
| >>> list(rrulestr(""" | ||
| ... DTSTART:19970902T090000 | ||
| ... RRULE:FREQ=DAILY;INTERVAL=10;COUNT=5 | ||
| ... """)) | ||
| [datetime.datetime(1997, 9, 2, 9, 0), | ||
| datetime.datetime(1997, 9, 12, 9, 0), | ||
| datetime.datetime(1997, 9, 22, 9, 0), | ||
| datetime.datetime(1997, 10, 2, 9, 0), | ||
| datetime.datetime(1997, 10, 12, 9, 0)] | ||
| Same thing, but passing only the `RRULE` value. | ||
| .. doctest:: rrulestr | ||
| :options: +NORMALIZE_WHITESPACE | ||
| >>> list(rrulestr("FREQ=DAILY;INTERVAL=10;COUNT=5", | ||
| ... dtstart=parse("19970902T090000"))) | ||
| [datetime.datetime(1997, 9, 2, 9, 0), | ||
| datetime.datetime(1997, 9, 12, 9, 0), | ||
| datetime.datetime(1997, 9, 22, 9, 0), | ||
| datetime.datetime(1997, 10, 2, 9, 0), | ||
| datetime.datetime(1997, 10, 12, 9, 0)] | ||
| Notice that when using a single rule, it returns an | ||
| `rrule` instance, unless `forceset` was used. | ||
| .. doctest:: rrulestr | ||
| :options: +ELLIPSIS | ||
| >>> rrulestr("FREQ=DAILY;INTERVAL=10;COUNT=5") | ||
| <dateutil.rrule.rrule object at 0x...> | ||
| >>> rrulestr(""" | ||
| ... DTSTART:19970902T090000 | ||
| ... RRULE:FREQ=DAILY;INTERVAL=10;COUNT=5 | ||
| ... """) | ||
| <dateutil.rrule.rrule object at 0x...> | ||
| >>> rrulestr("FREQ=DAILY;INTERVAL=10;COUNT=5", forceset=True) | ||
| <dateutil.rrule.rruleset object at 0x...> | ||
| But when an `rruleset` is needed, it is automatically used. | ||
| .. doctest:: rrulestr | ||
| :options: +ELLIPSIS | ||
| >>> rrulestr(""" | ||
| ... DTSTART:19970902T090000 | ||
| ... RRULE:FREQ=DAILY;INTERVAL=10;COUNT=5 | ||
| ... RRULE:FREQ=DAILY;INTERVAL=5;COUNT=3 | ||
| ... """) | ||
| <dateutil.rrule.rruleset object at 0x...> | ||
| parse examples | ||
| ----------- | ||
| The following code will prepare the environment: | ||
| .. doctest:: tz | ||
| >>> from dateutil.parser import * | ||
| >>> from dateutil.tz import * | ||
| >>> from datetime import * | ||
| >>> TZOFFSETS = {"BRST": -10800} | ||
| >>> BRSTTZ = tzoffset("BRST", -10800) | ||
| >>> DEFAULT = datetime(2003, 9, 25) | ||
| Some simple examples based on the `date` command, using the | ||
| `ZOFFSET` dictionary to provide the BRST timezone offset. | ||
| .. doctest:: tz | ||
| :options: +NORMALIZE_WHITESPACE | ||
| >>> parse("Thu Sep 25 10:36:28 BRST 2003", tzinfos=TZOFFSETS) | ||
| datetime.datetime(2003, 9, 25, 10, 36, 28, | ||
| tzinfo=tzoffset('BRST', -10800)) | ||
| >>> parse("2003 10:36:28 BRST 25 Sep Thu", tzinfos=TZOFFSETS) | ||
| datetime.datetime(2003, 9, 25, 10, 36, 28, | ||
| tzinfo=tzoffset('BRST', -10800)) | ||
| Notice that since BRST is my local timezone, parsing it without | ||
| further timezone settings will yield a `tzlocal` timezone. | ||
| .. doctest:: tz | ||
| >>> parse("Thu Sep 25 10:36:28 BRST 2003") | ||
| datetime.datetime(2003, 9, 25, 10, 36, 28, tzinfo=tzlocal()) | ||
| We can also ask to ignore the timezone explicitly: | ||
| .. doctest:: tz | ||
| >>> parse("Thu Sep 25 10:36:28 BRST 2003", ignoretz=True) | ||
| datetime.datetime(2003, 9, 25, 10, 36, 28) | ||
| That's the same as processing a string without timezone: | ||
| .. doctest:: tz | ||
| >>> parse("Thu Sep 25 10:36:28 2003") | ||
| datetime.datetime(2003, 9, 25, 10, 36, 28) | ||
| Without the year, but passing our `DEFAULT` datetime to return | ||
| the same year, no mattering what year we currently are in: | ||
| .. doctest:: tz | ||
| >>> parse("Thu Sep 25 10:36:28", default=DEFAULT) | ||
| datetime.datetime(2003, 9, 25, 10, 36, 28) | ||
| Strip it further: | ||
| .. doctest:: tz | ||
| >>> parse("Thu Sep 10:36:28", default=DEFAULT) | ||
| datetime.datetime(2003, 9, 25, 10, 36, 28) | ||
| >>> parse("Thu 10:36:28", default=DEFAULT) | ||
| datetime.datetime(2003, 9, 25, 10, 36, 28) | ||
| >>> parse("Thu 10:36", default=DEFAULT) | ||
| datetime.datetime(2003, 9, 25, 10, 36) | ||
| >>> parse("10:36", default=DEFAULT) | ||
| datetime.datetime(2003, 9, 25, 10, 36) | ||
| Strip in a different way: | ||
| .. doctest:: tz | ||
| >>> parse("Thu Sep 25 2003") | ||
| datetime.datetime(2003, 9, 25, 0, 0) | ||
| >>> parse("Sep 25 2003") | ||
| datetime.datetime(2003, 9, 25, 0, 0) | ||
| >>> parse("Sep 2003", default=DEFAULT) | ||
| datetime.datetime(2003, 9, 25, 0, 0) | ||
| >>> parse("Sep", default=DEFAULT) | ||
| datetime.datetime(2003, 9, 25, 0, 0) | ||
| >>> parse("2003", default=DEFAULT) | ||
| datetime.datetime(2003, 9, 25, 0, 0) | ||
| Another format, based on `date -R` (RFC822): | ||
| .. doctest:: tz | ||
| :options: +NORMALIZE_WHITESPACE | ||
| >>> parse("Thu, 25 Sep 2003 10:49:41 -0300") | ||
| datetime.datetime(2003, 9, 25, 10, 49, 41, | ||
| tzinfo=tzoffset(None, -10800)) | ||
| ISO format: | ||
| .. doctest:: tz | ||
| :options: +NORMALIZE_WHITESPACE | ||
| >>> parse("2003-09-25T10:49:41.5-03:00") | ||
| datetime.datetime(2003, 9, 25, 10, 49, 41, 500000, | ||
| tzinfo=tzoffset(None, -10800)) | ||
| Some variations: | ||
| .. doctest:: tz | ||
| >>> parse("2003-09-25T10:49:41") | ||
| datetime.datetime(2003, 9, 25, 10, 49, 41) | ||
| >>> parse("2003-09-25T10:49") | ||
| datetime.datetime(2003, 9, 25, 10, 49) | ||
| >>> parse("2003-09-25T10") | ||
| datetime.datetime(2003, 9, 25, 10, 0) | ||
| >>> parse("2003-09-25") | ||
| datetime.datetime(2003, 9, 25, 0, 0) | ||
| ISO format, without separators: | ||
| .. doctest:: tz | ||
| :options: +NORMALIZE_WHITESPACE | ||
| >>> parse("20030925T104941.5-0300") | ||
| datetime.datetime(2003, 9, 25, 10, 49, 41, 500000, | ||
| tzinfo=tzoffset(None, -10800)) | ||
| >>> parse("20030925T104941-0300") | ||
| datetime.datetime(2003, 9, 25, 10, 49, 41, | ||
| tzinfo=tzoffset(None, -10800)) | ||
| >>> parse("20030925T104941") | ||
| datetime.datetime(2003, 9, 25, 10, 49, 41) | ||
| >>> parse("20030925T1049") | ||
| datetime.datetime(2003, 9, 25, 10, 49) | ||
| >>> parse("20030925T10") | ||
| datetime.datetime(2003, 9, 25, 10, 0) | ||
| >>> parse("20030925") | ||
| datetime.datetime(2003, 9, 25, 0, 0) | ||
| Everything together. | ||
| .. doctest:: tz | ||
| >>> parse("199709020900") | ||
| datetime.datetime(1997, 9, 2, 9, 0) | ||
| >>> parse("19970902090059") | ||
| datetime.datetime(1997, 9, 2, 9, 0, 59) | ||
| Different date orderings: | ||
| .. doctest:: tz | ||
| >>> parse("2003-09-25") | ||
| datetime.datetime(2003, 9, 25, 0, 0) | ||
| >>> parse("2003-Sep-25") | ||
| datetime.datetime(2003, 9, 25, 0, 0) | ||
| >>> parse("25-Sep-2003") | ||
| datetime.datetime(2003, 9, 25, 0, 0) | ||
| >>> parse("Sep-25-2003") | ||
| datetime.datetime(2003, 9, 25, 0, 0) | ||
| >>> parse("09-25-2003") | ||
| datetime.datetime(2003, 9, 25, 0, 0) | ||
| >>> parse("25-09-2003") | ||
| datetime.datetime(2003, 9, 25, 0, 0) | ||
| Check some ambiguous dates: | ||
| .. doctest:: tz | ||
| >>> parse("10-09-2003") | ||
| datetime.datetime(2003, 10, 9, 0, 0) | ||
| >>> parse("10-09-2003", dayfirst=True) | ||
| datetime.datetime(2003, 9, 10, 0, 0) | ||
| >>> parse("10-09-03") | ||
| datetime.datetime(2003, 10, 9, 0, 0) | ||
| >>> parse("10-09-03", yearfirst=True) | ||
| datetime.datetime(2010, 9, 3, 0, 0) | ||
| Other date separators are allowed: | ||
| .. doctest:: tz | ||
| >>> parse("2003.Sep.25") | ||
| datetime.datetime(2003, 9, 25, 0, 0) | ||
| >>> parse("2003/09/25") | ||
| datetime.datetime(2003, 9, 25, 0, 0) | ||
| Even with spaces: | ||
| .. doctest:: tz | ||
| >>> parse("2003 Sep 25") | ||
| datetime.datetime(2003, 9, 25, 0, 0) | ||
| >>> parse("2003 09 25") | ||
| datetime.datetime(2003, 9, 25, 0, 0) | ||
| Hours with letters work: | ||
| .. doctest:: tz | ||
| >>> parse("10h36m28.5s", default=DEFAULT) | ||
| datetime.datetime(2003, 9, 25, 10, 36, 28, 500000) | ||
| >>> parse("01s02h03m", default=DEFAULT) | ||
| datetime.datetime(2003, 9, 25, 2, 3, 1) | ||
| >>> parse("01h02m03", default=DEFAULT) | ||
| datetime.datetime(2003, 9, 25, 1, 2, 3) | ||
| >>> parse("01h02", default=DEFAULT) | ||
| datetime.datetime(2003, 9, 25, 1, 2) | ||
| >>> parse("01h02s", default=DEFAULT) | ||
| datetime.datetime(2003, 9, 25, 1, 0, 2) | ||
| With AM/PM: | ||
| .. doctest:: tz | ||
| >>> parse("10h am", default=DEFAULT) | ||
| datetime.datetime(2003, 9, 25, 10, 0) | ||
| >>> parse("10pm", default=DEFAULT) | ||
| datetime.datetime(2003, 9, 25, 22, 0) | ||
| >>> parse("12:00am", default=DEFAULT) | ||
| datetime.datetime(2003, 9, 25, 0, 0) | ||
| >>> parse("12pm", default=DEFAULT) | ||
| datetime.datetime(2003, 9, 25, 12, 0) | ||
| Some special treating for ''pertain'' relations: | ||
| .. doctest:: tz | ||
| >>> parse("Sep 03", default=DEFAULT) | ||
| datetime.datetime(2003, 9, 3, 0, 0) | ||
| >>> parse("Sep of 03", default=DEFAULT) | ||
| datetime.datetime(2003, 9, 25, 0, 0) | ||
| Fuzzy parsing: | ||
| .. doctest:: tz | ||
| :options: +NORMALIZE_WHITESPACE | ||
| >>> s = "Today is 25 of September of 2003, exactly " \ | ||
| ... "at 10:49:41 with timezone -03:00." | ||
| >>> parse(s, fuzzy=True) | ||
| datetime.datetime(2003, 9, 25, 10, 49, 41, | ||
| tzinfo=tzoffset(None, -10800)) | ||
| Other random formats: | ||
| .. doctest:: tz | ||
| >>> parse("Wed, July 10, '96") | ||
| datetime.datetime(1996, 7, 10, 0, 0) | ||
| >>> parse("1996.07.10 AD at 15:08:56 PDT", ignoretz=True) | ||
| datetime.datetime(1996, 7, 10, 15, 8, 56) | ||
| >>> parse("Tuesday, April 12, 1952 AD 3:30:42pm PST", ignoretz=True) | ||
| datetime.datetime(1952, 4, 12, 15, 30, 42) | ||
| >>> parse("November 5, 1994, 8:15:30 am EST", ignoretz=True) | ||
| datetime.datetime(1994, 11, 5, 8, 15, 30) | ||
| >>> parse("3rd of May 2001") | ||
| datetime.datetime(2001, 5, 3, 0, 0) | ||
| >>> parse("5:50 A.M. on June 13, 1990") | ||
| datetime.datetime(1990, 6, 13, 5, 50) | ||
| tzutc examples | ||
| -------------- | ||
| .. doctest:: tzutc | ||
| >>> from datetime import * | ||
| >>> from dateutil.tz import * | ||
| >>> datetime.now() | ||
| datetime.datetime(2003, 9, 27, 9, 40, 1, 521290) | ||
| >>> datetime.now(tzutc()) | ||
| datetime.datetime(2003, 9, 27, 12, 40, 12, 156379, tzinfo=tzutc()) | ||
| >>> datetime.now(tzutc()).tzname() | ||
| 'UTC' | ||
| tzoffset examples | ||
| ----------------- | ||
| .. doctest:: tzoffset | ||
| :options: +NORMALIZE_WHITESPACE | ||
| >>> from datetime import * | ||
| >>> from dateutil.tz import * | ||
| >>> datetime.now(tzoffset("BRST", -10800)) | ||
| datetime.datetime(2003, 9, 27, 9, 52, 43, 624904, | ||
| tzinfo=tzinfo=tzoffset('BRST', -10800)) | ||
| >>> datetime.now(tzoffset("BRST", -10800)).tzname() | ||
| 'BRST' | ||
| >>> datetime.now(tzoffset("BRST", -10800)).astimezone(tzutc()) | ||
| datetime.datetime(2003, 9, 27, 12, 53, 11, 446419, | ||
| tzinfo=tzutc()) | ||
| tzlocal examples | ||
| ---------------- | ||
| .. doctest:: tzlocal | ||
| >>> from datetime import * | ||
| >>> from dateutil.tz import * | ||
| >>> datetime.now(tzlocal()) | ||
| datetime.datetime(2003, 9, 27, 10, 1, 43, 673605, | ||
| tzinfo=tzlocal()) | ||
| >>> datetime.now(tzlocal()).tzname() | ||
| 'BRST' | ||
| >>> datetime.now(tzlocal()).astimezone(tzoffset(None, 0)) | ||
| datetime.datetime(2003, 9, 27, 13, 3, 0, 11493, | ||
| tzinfo=tzoffset(None, 0)) | ||
| tzstr examples | ||
| -------------- | ||
| Here are examples of the recognized formats: | ||
| * `EST5EDT` | ||
| * `EST5EDT,4,0,6,7200,10,0,26,7200,3600` | ||
| * `EST5EDT,4,1,0,7200,10,-1,0,7200,3600` | ||
| * `EST5EDT4,M4.1.0/02:00:00,M10-5-0/02:00` | ||
| * `EST5EDT4,95/02:00:00,298/02:00` | ||
| * `EST5EDT4,J96/02:00:00,J299/02:00` | ||
| Notice that if daylight information is not present, but a | ||
| daylight abbreviation was provided, `tzstr` will follow the | ||
| convention of using the first sunday of April to start daylight | ||
| saving, and the last sunday of October to end it. If start or | ||
| end time is not present, 2AM will be used, and if the daylight | ||
| offset is not present, the standard offset plus one hour will | ||
| be used. This convention is the same as used in the GNU libc. | ||
| This also means that some of the above examples are exactly | ||
| equivalent, and all of these examples are equivalent | ||
| in the year of 2003. | ||
| Here is the example mentioned in the | ||
| [http://www.python.org/doc/current/lib/module-time.html time module documentation]. | ||
| .. testsetup:: tzstr | ||
| import os | ||
| import time | ||
| from datetime import datetime | ||
| from dateutil.tz import tzstr | ||
| .. doctest:: tzstr | ||
| >>> os.environ['TZ'] = 'EST+05EDT,M4.1.0,M10.5.0' | ||
| >>> time.tzset() | ||
| >>> time.strftime('%X %x %Z') | ||
| '02:07:36 05/08/03 EDT' | ||
| >>> os.environ['TZ'] = 'AEST-10AEDT-11,M10.5.0,M3.5.0' | ||
| >>> time.tzset() | ||
| >>> time.strftime('%X %x %Z') | ||
| '16:08:12 05/08/03 AEST' | ||
| And here is an example showing the same information using `tzstr`, | ||
| without touching system settings. | ||
| .. doctest:: tzstr | ||
| >>> tz1 = tzstr('EST+05EDT,M4.1.0,M10.5.0') | ||
| >>> tz2 = tzstr('AEST-10AEDT-11,M10.5.0,M3.5.0') | ||
| >>> dt = datetime(2003, 5, 8, 2, 7, 36, tzinfo=tz1) | ||
| >>> dt.strftime('%X %x %Z') | ||
| '02:07:36 05/08/03 EDT' | ||
| >>> dt.astimezone(tz2).strftime('%X %x %Z') | ||
| '16:07:36 05/08/03 AEST' | ||
| Are these really equivalent? | ||
| .. doctest:: tzstr | ||
| >>> tzstr('EST5EDT') == tzstr('EST5EDT,4,1,0,7200,10,-1,0,7200,3600') | ||
| True | ||
| Check the daylight limit. | ||
| .. doctest:: tzstr | ||
| >>> tz = tzstr('EST+05EDT,M4.1.0,M10.5.0') | ||
| >>> datetime(2003, 4, 6, 1, 59, tzinfo=tz).tzname() | ||
| 'EST' | ||
| >>> datetime(2003, 4, 6, 2, 00, tzinfo=tz).tzname() | ||
| 'EDT' | ||
| >>> datetime(2003, 10, 26, 0, 59, tzinfo=tz).tzname() | ||
| 'EDT' | ||
| >>> datetime(2003, 10, 26, 1, 00, tzinfo=tz).tzname() | ||
| 'EST' | ||
| tzrange examples | ||
| ---------------- | ||
| .. testsetup:: tzrange | ||
| from dateutil.tz import tzrange, tzstr | ||
| .. doctest:: tzrange | ||
| >>> tzstr('EST5EDT') == tzrange("EST", -18000, "EDT") | ||
| True | ||
| >>> from dateutil.relativedelta import * | ||
| >>> range1 = tzrange("EST", -18000, "EDT") | ||
| >>> range2 = tzrange("EST", -18000, "EDT", -14400, | ||
| ... relativedelta(hours=+2, month=4, day=1, | ||
| ... weekday=SU(+1)), | ||
| ... relativedelta(hours=+1, month=10, day=31, | ||
| ... weekday=SU(-1))) | ||
| >>> tzstr('EST5EDT') == range1 == range2 | ||
| True | ||
| Notice a minor detail in the last example: while the DST should end | ||
| at 2AM, the delta will catch 1AM. That's because the daylight saving | ||
| time should end at 2AM standard time (the difference between STD and | ||
| DST is 1h in the given example) instead of the DST time. That's how | ||
| the `tzinfo` subtypes should deal with the extra hour that happens | ||
| when going back to the standard time. Check | ||
| [http://www.python.org/doc/current/lib/datetime-tzinfo.html tzinfo documentation] | ||
| for more information. | ||
| tzfile examples | ||
| --------------- | ||
| .. testsetup:: tzfile | ||
| from datetime import datetime | ||
| from dateutil.tz import tzfile, tzutc | ||
| .. doctest:: tzfile | ||
| :options: +NORMALIZE_WHITESPACE | ||
| >>> tz = tzfile("/etc/localtime") | ||
| >>> datetime.now(tz) | ||
| datetime.datetime(2003, 9, 27, 12, 3, 48, 392138, | ||
| tzinfo=tzfile('/etc/localtime')) | ||
| >>> datetime.now(tz).astimezone(tzutc()) | ||
| datetime.datetime(2003, 9, 27, 15, 3, 53, 70863, | ||
| tzinfo=tzutc()) | ||
| >>> datetime.now(tz).tzname() | ||
| 'BRST' | ||
| >>> datetime(2003, 1, 1, tzinfo=tz).tzname() | ||
| 'BRDT' | ||
| Check the daylight limit. | ||
| .. doctest:: tzfile | ||
| >>> tz = tzfile('/usr/share/zoneinfo/EST5EDT') | ||
| >>> datetime(2003, 4, 6, 1, 59, tzinfo=tz).tzname() | ||
| 'EST' | ||
| >>> datetime(2003, 4, 6, 2, 00, tzinfo=tz).tzname() | ||
| 'EDT' | ||
| >>> datetime(2003, 10, 26, 0, 59, tzinfo=tz).tzname() | ||
| 'EDT' | ||
| >>> datetime(2003, 10, 26, 1, 00, tzinfo=tz).tzname() | ||
| 'EST' | ||
| tzical examples | ||
| --------------- | ||
| Here is a sample file extracted from the RFC. This file defines | ||
| the `EST5EDT` timezone, and will be used in the following example. | ||
| .. include:: samples/EST5EDT.ics | ||
| :literal: | ||
| And here is an example exploring a `tzical` type: | ||
| .. doctest:: tzfile | ||
| >>> from dateutil.tz import *; from datetime import * | ||
| >>> tz = tzical('samples/EST5EDT.ics') | ||
| >>> tz.keys() | ||
| ['US-Eastern'] | ||
| >>> est = tz.get('US-Eastern') | ||
| >>> est | ||
| <tzicalvtz 'US-Eastern'> | ||
| >>> datetime.now(est) | ||
| datetime.datetime(2003, 10, 6, 19, 44, 18, 667987, | ||
| tzinfo=<tzicalvtz 'US-Eastern'>) | ||
| >>> est == tz.get() | ||
| True | ||
| Let's check the daylight ranges, as usual: | ||
| .. doctest:: tzfile | ||
| >>> datetime(2003, 4, 6, 1, 59, tzinfo=est).tzname() | ||
| 'EST' | ||
| >>> datetime(2003, 4, 6, 2, 00, tzinfo=est).tzname() | ||
| 'EDT' | ||
| >>> datetime(2003, 10, 26, 0, 59, tzinfo=est).tzname() | ||
| 'EDT' | ||
| >>> datetime(2003, 10, 26, 1, 00, tzinfo=est).tzname() | ||
| 'EST' | ||
| tzwin examples | ||
| -------------- | ||
| .. doctest:: tzwin | ||
| >>> tz = tzwin("E. South America Standard Time") | ||
| tzwinlocal examples | ||
| ------------------- | ||
| .. doctest:: tzwinlocal | ||
| >>> tz = tzwinlocal() | ||
| # vim:ts=4:sw=4:et |
| .. dateutil documentation master file, created by | ||
| sphinx-quickstart on Thu Nov 20 23:18:41 2014. | ||
| You can adapt this file completely to your liking, but it should at least | ||
| contain the root `toctree` directive. | ||
| .. include:: ../README.rst | ||
| Documentation | ||
| ============= | ||
| Contents: | ||
| .. toctree:: | ||
| :maxdepth: 2 | ||
| self | ||
| easter | ||
| parser | ||
| relativedelta | ||
| rrule | ||
| tz | ||
| zoneinfo | ||
| examples | ||
| Indices and tables | ||
| ================== | ||
| * :ref:`genindex` | ||
| * :ref:`modindex` | ||
| * :ref:`search` | ||
-242
| @ECHO OFF | ||
| REM Command file for Sphinx documentation | ||
| if "%SPHINXBUILD%" == "" ( | ||
| set SPHINXBUILD=sphinx-build | ||
| ) | ||
| set BUILDDIR=_build | ||
| set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . | ||
| set I18NSPHINXOPTS=%SPHINXOPTS% . | ||
| if NOT "%PAPER%" == "" ( | ||
| set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% | ||
| set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% | ||
| ) | ||
| if "%1" == "" goto help | ||
| if "%1" == "help" ( | ||
| :help | ||
| echo.Please use `make ^<target^>` where ^<target^> is one of | ||
| echo. html to make standalone HTML files | ||
| echo. dirhtml to make HTML files named index.html in directories | ||
| echo. singlehtml to make a single large HTML file | ||
| echo. pickle to make pickle files | ||
| echo. json to make JSON files | ||
| echo. htmlhelp to make HTML files and a HTML help project | ||
| echo. qthelp to make HTML files and a qthelp project | ||
| echo. devhelp to make HTML files and a Devhelp project | ||
| echo. epub to make an epub | ||
| echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter | ||
| echo. text to make text files | ||
| echo. man to make manual pages | ||
| echo. texinfo to make Texinfo files | ||
| echo. gettext to make PO message catalogs | ||
| echo. changes to make an overview over all changed/added/deprecated items | ||
| echo. xml to make Docutils-native XML files | ||
| echo. pseudoxml to make pseudoxml-XML files for display purposes | ||
| echo. linkcheck to check all external links for integrity | ||
| echo. doctest to run all doctests embedded in the documentation if enabled | ||
| goto end | ||
| ) | ||
| if "%1" == "clean" ( | ||
| for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i | ||
| del /q /s %BUILDDIR%\* | ||
| goto end | ||
| ) | ||
| %SPHINXBUILD% 2> nul | ||
| if errorlevel 9009 ( | ||
| echo. | ||
| echo.The 'sphinx-build' command was not found. Make sure you have Sphinx | ||
| echo.installed, then set the SPHINXBUILD environment variable to point | ||
| echo.to the full path of the 'sphinx-build' executable. Alternatively you | ||
| echo.may add the Sphinx directory to PATH. | ||
| echo. | ||
| echo.If you don't have Sphinx installed, grab it from | ||
| echo.http://sphinx-doc.org/ | ||
| exit /b 1 | ||
| ) | ||
| if "%1" == "html" ( | ||
| %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html | ||
| if errorlevel 1 exit /b 1 | ||
| echo. | ||
| echo.Build finished. The HTML pages are in %BUILDDIR%/html. | ||
| goto end | ||
| ) | ||
| if "%1" == "dirhtml" ( | ||
| %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml | ||
| if errorlevel 1 exit /b 1 | ||
| echo. | ||
| echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. | ||
| goto end | ||
| ) | ||
| if "%1" == "singlehtml" ( | ||
| %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml | ||
| if errorlevel 1 exit /b 1 | ||
| echo. | ||
| echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. | ||
| goto end | ||
| ) | ||
| if "%1" == "pickle" ( | ||
| %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle | ||
| if errorlevel 1 exit /b 1 | ||
| echo. | ||
| echo.Build finished; now you can process the pickle files. | ||
| goto end | ||
| ) | ||
| if "%1" == "json" ( | ||
| %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json | ||
| if errorlevel 1 exit /b 1 | ||
| echo. | ||
| echo.Build finished; now you can process the JSON files. | ||
| goto end | ||
| ) | ||
| if "%1" == "htmlhelp" ( | ||
| %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp | ||
| if errorlevel 1 exit /b 1 | ||
| echo. | ||
| echo.Build finished; now you can run HTML Help Workshop with the ^ | ||
| .hhp project file in %BUILDDIR%/htmlhelp. | ||
| goto end | ||
| ) | ||
| if "%1" == "qthelp" ( | ||
| %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp | ||
| if errorlevel 1 exit /b 1 | ||
| echo. | ||
| echo.Build finished; now you can run "qcollectiongenerator" with the ^ | ||
| .qhcp project file in %BUILDDIR%/qthelp, like this: | ||
| echo.^> qcollectiongenerator %BUILDDIR%\qthelp\dateutil.qhcp | ||
| echo.To view the help file: | ||
| echo.^> assistant -collectionFile %BUILDDIR%\qthelp\dateutil.ghc | ||
| goto end | ||
| ) | ||
| if "%1" == "devhelp" ( | ||
| %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp | ||
| if errorlevel 1 exit /b 1 | ||
| echo. | ||
| echo.Build finished. | ||
| goto end | ||
| ) | ||
| if "%1" == "epub" ( | ||
| %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub | ||
| if errorlevel 1 exit /b 1 | ||
| echo. | ||
| echo.Build finished. The epub file is in %BUILDDIR%/epub. | ||
| goto end | ||
| ) | ||
| if "%1" == "latex" ( | ||
| %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex | ||
| if errorlevel 1 exit /b 1 | ||
| echo. | ||
| echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. | ||
| goto end | ||
| ) | ||
| if "%1" == "latexpdf" ( | ||
| %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex | ||
| cd %BUILDDIR%/latex | ||
| make all-pdf | ||
| cd %BUILDDIR%/.. | ||
| echo. | ||
| echo.Build finished; the PDF files are in %BUILDDIR%/latex. | ||
| goto end | ||
| ) | ||
| if "%1" == "latexpdfja" ( | ||
| %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex | ||
| cd %BUILDDIR%/latex | ||
| make all-pdf-ja | ||
| cd %BUILDDIR%/.. | ||
| echo. | ||
| echo.Build finished; the PDF files are in %BUILDDIR%/latex. | ||
| goto end | ||
| ) | ||
| if "%1" == "text" ( | ||
| %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text | ||
| if errorlevel 1 exit /b 1 | ||
| echo. | ||
| echo.Build finished. The text files are in %BUILDDIR%/text. | ||
| goto end | ||
| ) | ||
| if "%1" == "man" ( | ||
| %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man | ||
| if errorlevel 1 exit /b 1 | ||
| echo. | ||
| echo.Build finished. The manual pages are in %BUILDDIR%/man. | ||
| goto end | ||
| ) | ||
| if "%1" == "texinfo" ( | ||
| %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo | ||
| if errorlevel 1 exit /b 1 | ||
| echo. | ||
| echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. | ||
| goto end | ||
| ) | ||
| if "%1" == "gettext" ( | ||
| %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale | ||
| if errorlevel 1 exit /b 1 | ||
| echo. | ||
| echo.Build finished. The message catalogs are in %BUILDDIR%/locale. | ||
| goto end | ||
| ) | ||
| if "%1" == "changes" ( | ||
| %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes | ||
| if errorlevel 1 exit /b 1 | ||
| echo. | ||
| echo.The overview file is in %BUILDDIR%/changes. | ||
| goto end | ||
| ) | ||
| if "%1" == "linkcheck" ( | ||
| %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck | ||
| if errorlevel 1 exit /b 1 | ||
| echo. | ||
| echo.Link check complete; look for any errors in the above output ^ | ||
| or in %BUILDDIR%/linkcheck/output.txt. | ||
| goto end | ||
| ) | ||
| if "%1" == "doctest" ( | ||
| %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest | ||
| if errorlevel 1 exit /b 1 | ||
| echo. | ||
| echo.Testing of doctests in the sources finished, look at the ^ | ||
| results in %BUILDDIR%/doctest/output.txt. | ||
| goto end | ||
| ) | ||
| if "%1" == "xml" ( | ||
| %SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml | ||
| if errorlevel 1 exit /b 1 | ||
| echo. | ||
| echo.Build finished. The XML files are in %BUILDDIR%/xml. | ||
| goto end | ||
| ) | ||
| if "%1" == "pseudoxml" ( | ||
| %SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml | ||
| if errorlevel 1 exit /b 1 | ||
| echo. | ||
| echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml. | ||
| goto end | ||
| ) | ||
| :end |
-177
| # Makefile for Sphinx documentation | ||
| # | ||
| # You can set these variables from the command line. | ||
| SPHINXOPTS = | ||
| SPHINXBUILD = sphinx-build | ||
| PAPER = | ||
| BUILDDIR = _build | ||
| # User-friendly check for sphinx-build | ||
| ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) | ||
| $(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) | ||
| endif | ||
| # Internal variables. | ||
| PAPEROPT_a4 = -D latex_paper_size=a4 | ||
| PAPEROPT_letter = -D latex_paper_size=letter | ||
| ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . | ||
| # the i18n builder cannot share the environment and doctrees with the others | ||
| I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . | ||
| .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext | ||
| help: | ||
| @echo "Please use \`make <target>' where <target> is one of" | ||
| @echo " html to make standalone HTML files" | ||
| @echo " dirhtml to make HTML files named index.html in directories" | ||
| @echo " singlehtml to make a single large HTML file" | ||
| @echo " pickle to make pickle files" | ||
| @echo " json to make JSON files" | ||
| @echo " htmlhelp to make HTML files and a HTML help project" | ||
| @echo " qthelp to make HTML files and a qthelp project" | ||
| @echo " devhelp to make HTML files and a Devhelp project" | ||
| @echo " epub to make an epub" | ||
| @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" | ||
| @echo " latexpdf to make LaTeX files and run them through pdflatex" | ||
| @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" | ||
| @echo " text to make text files" | ||
| @echo " man to make manual pages" | ||
| @echo " texinfo to make Texinfo files" | ||
| @echo " info to make Texinfo files and run them through makeinfo" | ||
| @echo " gettext to make PO message catalogs" | ||
| @echo " changes to make an overview of all changed/added/deprecated items" | ||
| @echo " xml to make Docutils-native XML files" | ||
| @echo " pseudoxml to make pseudoxml-XML files for display purposes" | ||
| @echo " linkcheck to check all external links for integrity" | ||
| @echo " doctest to run all doctests embedded in the documentation (if enabled)" | ||
| clean: | ||
| rm -rf $(BUILDDIR)/* | ||
| html: | ||
| $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html | ||
| @echo | ||
| @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." | ||
| dirhtml: | ||
| $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml | ||
| @echo | ||
| @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." | ||
| singlehtml: | ||
| $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml | ||
| @echo | ||
| @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." | ||
| pickle: | ||
| $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle | ||
| @echo | ||
| @echo "Build finished; now you can process the pickle files." | ||
| json: | ||
| $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json | ||
| @echo | ||
| @echo "Build finished; now you can process the JSON files." | ||
| htmlhelp: | ||
| $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp | ||
| @echo | ||
| @echo "Build finished; now you can run HTML Help Workshop with the" \ | ||
| ".hhp project file in $(BUILDDIR)/htmlhelp." | ||
| qthelp: | ||
| $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp | ||
| @echo | ||
| @echo "Build finished; now you can run "qcollectiongenerator" with the" \ | ||
| ".qhcp project file in $(BUILDDIR)/qthelp, like this:" | ||
| @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/dateutil.qhcp" | ||
| @echo "To view the help file:" | ||
| @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/dateutil.qhc" | ||
| devhelp: | ||
| $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp | ||
| @echo | ||
| @echo "Build finished." | ||
| @echo "To view the help file:" | ||
| @echo "# mkdir -p $$HOME/.local/share/devhelp/dateutil" | ||
| @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/dateutil" | ||
| @echo "# devhelp" | ||
| epub: | ||
| $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub | ||
| @echo | ||
| @echo "Build finished. The epub file is in $(BUILDDIR)/epub." | ||
| latex: | ||
| $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex | ||
| @echo | ||
| @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." | ||
| @echo "Run \`make' in that directory to run these through (pdf)latex" \ | ||
| "(use \`make latexpdf' here to do that automatically)." | ||
| latexpdf: | ||
| $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex | ||
| @echo "Running LaTeX files through pdflatex..." | ||
| $(MAKE) -C $(BUILDDIR)/latex all-pdf | ||
| @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." | ||
| latexpdfja: | ||
| $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex | ||
| @echo "Running LaTeX files through platex and dvipdfmx..." | ||
| $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja | ||
| @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." | ||
| text: | ||
| $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text | ||
| @echo | ||
| @echo "Build finished. The text files are in $(BUILDDIR)/text." | ||
| man: | ||
| $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man | ||
| @echo | ||
| @echo "Build finished. The manual pages are in $(BUILDDIR)/man." | ||
| texinfo: | ||
| $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo | ||
| @echo | ||
| @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." | ||
| @echo "Run \`make' in that directory to run these through makeinfo" \ | ||
| "(use \`make info' here to do that automatically)." | ||
| info: | ||
| $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo | ||
| @echo "Running Texinfo files through makeinfo..." | ||
| make -C $(BUILDDIR)/texinfo info | ||
| @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." | ||
| gettext: | ||
| $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale | ||
| @echo | ||
| @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." | ||
| changes: | ||
| $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes | ||
| @echo | ||
| @echo "The overview file is in $(BUILDDIR)/changes." | ||
| linkcheck: | ||
| $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck | ||
| @echo | ||
| @echo "Link check complete; look for any errors in the above output " \ | ||
| "or in $(BUILDDIR)/linkcheck/output.txt." | ||
| doctest: | ||
| $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest | ||
| @echo "Testing of doctests in the sources finished, look at the " \ | ||
| "results in $(BUILDDIR)/doctest/output.txt." | ||
| xml: | ||
| $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml | ||
| @echo | ||
| @echo "Build finished. The XML files are in $(BUILDDIR)/xml." | ||
| pseudoxml: | ||
| $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml | ||
| @echo | ||
| @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." |
| ====== | ||
| parser | ||
| ====== | ||
| .. automodule:: dateutil.parser | ||
| :members: | ||
| :undoc-members: |
| ============= | ||
| relativedelta | ||
| ============= | ||
| .. automodule:: dateutil.relativedelta | ||
| :members: | ||
| :undoc-members: |
| ===== | ||
| rrule | ||
| ===== | ||
| .. automodule:: dateutil.rrule | ||
| :members: | ||
| :undoc-members: |
Sorry, the diff of this file is not supported yet
| == | ||
| tz | ||
| == | ||
| .. automodule:: dateutil.tz | ||
| :members: | ||
| :undoc-members: |
| ======== | ||
| zoneinfo | ||
| ======== | ||
| .. automodule:: dateutil.zoneinfo | ||
| :members: | ||
| :undoc-members: | ||
| zonefile_metadata | ||
| ----------------- | ||
| The zonefile metadata defines the version and exact location of | ||
| the timezone database to download. It is used in the :ref:`updatezinfo.py` | ||
| script. A json encoded file is included in the source-code, and | ||
| within each tar file we produce. The json file is attached here: | ||
| .. literalinclude:: ../zonefile_metadata.json | ||
| :language: json |
Sorry, the diff of this file is not supported yet
-15
| [tox] | ||
| envlist = | ||
| py26, | ||
| py27, | ||
| py32, | ||
| py33, | ||
| py34, | ||
| py35, | ||
| py36 | ||
| [testenv] | ||
| commands = python setup.py test -q {posargs} | ||
| deps = | ||
| py26: unittest2 | ||
| six |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
759197
-7.62%38
-35.59%12500
-0.34%