isoweek-1.3.3/0000755000175000017500000000000013033210716011262 5ustar hlehleisoweek-1.3.3/README.rst0000644000175000017500000000727313033201271012756 0ustar hlehleISO Week ======== The isoweek module provide the class *Week*. Instances represent specific weeks spanning Monday to Sunday. There are 52 or 53 numbered weeks in a year. Week 1 is defined to be the first week with 4 or more days in January. It's called isoweek because this is the week definition of ISO 8601. This standard also define a notation for identifying weeks; yyyyWww (where the "W" is a literal). An example is "2011W08" which denotes the 8th week of year 2011. *Week* instances stringify to this form. See also http://en.wikipedia.org/wiki/ISO_week_date The *Week* instances are light weight and immutable with an interface similar to the datetime.date objects. Example code:: from isoweek import Week w = Week(2011, 20) print "Week %s starts on %s" % (w, w.monday()) print "Current week number is", Week.thisweek().week print "Next week is", Week.thisweek() + 1 Reference ---------- Constructor: *class* isoweek.Week(*year*, *week*) All arguments are required. Arguments should be ints. If the week number isn't within the range of the given year, the year is adjusted to make week number within range. The final year must be within range 1 to 9999. If not ValueError is raised. Other constructors, all class methods: *classmethod* Week.thisweek() Return the current week (local time). *classmethod* Week.fromordinal(*ordinal*) Return the week corresponding to the proleptic Gregorian ordinal, where January 1 of year 1 starts the week with ordinal 1. *classmethod* Week.fromstring(*isostring*) Return a week initialized from an ISO formatted string like "2011W08" or "2011-W08". Note that weeks always stringify back in the former and more compact format. *classmethod* Week.withdate(*date*) Return the week that contains the given datetime.date. *classmethod* Week.weeks_of_year(*year*) Return an iterator over the weeks of the given year. *classmethod* Week.last_week_of_year(*year*) Return the last week of the given year. Instance attributes (read-only): Week.year Between 1 and 9999 inclusive. Week.week Between 1 and 53 inclusive (52 for most years). Supported operations: ==================== ========================================================== Operation Result ==================== ========================================================== week1 = week2 + int week2 is int weeks removed from week1. week1 = week2 - int Computes week2 such that week2 + int == week1 int = week1 - week2 Computes int such that week2 + int == week1 week1 < week2 week1 is considered less than week2 when week1 precedes week2 in time. ==================== ========================================================== Instance methods: Week.replace(*year*, *week*) Return a Week with the same value, except for those parameters given new values by whichever keyword arguments are specified. Week.toordinal() Return the proleptic Gregorian ordinal the week, where January 1 of year 1 starts the first week. Week.day(*num*) Return the given day of week as a datetime.date object. Day 0 is Monday. Week.monday(), Week.tuesday(),.. Week.sunday() Return the given day of week as a datetime.date object. Week.days() Return the 7 days of the week as a list. Week.contains(day) Check if the given datetime.date falls within the week. Week.isoformat() Return a string representing the week in ISO 8601 format; "yyyyWww". For example Week(2011, 8).isoformat() == '2011W08'. Week.__str__() For a Week w, str(w) is equivalent to w.isoformat() Week.__repr__() Return a string like "isoweek.Week(2011, 2)". isoweek-1.3.3/setup.cfg0000644000175000017500000000013013033210716013075 0ustar hlehle[bdist_wheel] universal = 1 [egg_info] tag_build = tag_date = 0 tag_svn_revision = 0 isoweek-1.3.3/CHANGES.txt0000644000175000017500000000176113033210564013101 0ustar hlehlev1.3.3, 2017-01-04 Update version numbers everywhere v1.3.2, 2017-01-04 Generate wheel v1.3.1, 2016-10-10 Documentation fixes v1.3.0, 2014-01-28 Fix: make sure week arithmetics preserve the Week class Added week.days() method Added week.contains(day) method v1.2.0, 2011-10-20 The module now works with Python 3. v1.1.0, 2011-10-10 Add min/max/resolution attibutes to Week (like datetime.date has) Introduce Week.last_week_of_year() method Support arithmethics with timedelta v1.0.1, 2011-10-07 Constructor failed for week 53 in years with 53 weeks v1.0.0, 2011-10-07 Allow "-" after year in Week.fromstring Documentation tweaks v0.2.0, 2011-09-06 Allow Unicode strings passed to Week.fromstring() Provide isoformat() method Provide replace() method Arithmetics with longs should work as well repr() in the same style as for datetime.date Improved documentation v0.1.0, 2011-09-05 Initial release. isoweek-1.3.3/isoweek.py0000644000175000017500000001441313033210421013276 0ustar hlehlefrom datetime import date, datetime, timedelta from collections import namedtuple __version__ = (1, 3, 3) import sys if sys.version >= '3': # compatiblity tweaks basestring = str long = int class Week(namedtuple('Week', ('year', 'week'))): """A Week represents a period of 7 days starting with a Monday. Weeks are identified by a year and week number within the year. This corresponds to the read-only attributes 'year' and 'week'. Week 1 of a year is defined to be the first week with 4 or more days in January. The preceeding week is either week 52 or 53 of the preceeding year. Week objects are tuples, and thus immutable, with an interface similar to the standard datetime.date class. """ __slots__ = () def __new__(cls, year, week): """Initialize a Week tuple with the given year and week number. The week number does not have to be within range. The numbers will be normalized if not. The year must be within the range 1 to 9999. """ if week < 1 or week > 52: return cls(year, 1) + (week - 1) if year < 1 or year > 9999: raise ValueError("year is out of range") return super(Week, cls).__new__(cls, year, week) @classmethod def thisweek(cls): """Return the current week (local time).""" return cls(*(date.today().isocalendar()[:2])) @classmethod def fromordinal(cls, ordinal): """Return the week corresponding to the proleptic Gregorian ordinal, where January 1 of year 1 starts the week with ordinal 1. """ if ordinal < 1: raise ValueError("ordinal must be >= 1") return super(Week, cls).__new__(cls, *(date.fromordinal((ordinal-1) * 7 + 1).isocalendar()[:2])) @classmethod def fromstring(cls, isostring): """Return a week initialized from an ISO formatted string like "2011W08" or "2011-W08".""" if isinstance(isostring, basestring) and len(isostring) == 7 and isostring[4] == 'W': return cls(int(isostring[0:4]), int(isostring[5:7])) elif isinstance(isostring, basestring) and len(isostring) == 8 and isostring[4:6] == '-W': return cls(int(isostring[0:4]), int(isostring[6:8])) else: raise ValueError("Week.tostring argument must be on the form W; got %r" % (isostring,)) @classmethod def withdate(cls, date): """Return the week that contains the given datetime.date""" return cls(*(date.isocalendar()[:2])) @classmethod def weeks_of_year(cls, year): """Return an iterator over the weeks of the given year. Years have either 52 or 53 weeks.""" w = cls(year, 1) while w.year == year: yield w w += 1 @classmethod def last_week_of_year(cls, year): """Return the last week of the given year. This week with either have week-number 52 or 53. This will be the same as Week(year+1, 0), but will even work for year 9999 where this expression would overflow. The first week of a given year is simply Week(year, 1), so there is no dedicated classmethod for that. """ if year == cls.max.year: return cls.max return cls(year+1, 0) def day(self, num): """Return the given day of week as a date object. Day 0 is the Monday.""" d = date(self.year, 1, 4) # The Jan 4th must be in week 1 according to ISO return d + timedelta(weeks=self.week-1, days=-d.weekday() + num) def monday(self): """Return the first day of the week as a date object""" return self.day(0) def tuesday(self): """Return the second day the week as a date object""" return self.day(1) def wednesday(self): """Return the third day the week as a date object""" return self.day(2) def thursday(self): """Return the fourth day the week as a date object""" return self.day(3) def friday(self): """Return the fifth day the week as a date object""" return self.day(4) def saturday(self): """Return the sixth day the week as a date object""" return self.day(5) def sunday(self): """Return the last day the week as a date object""" return self.day(6) def days(self): """Return the 7 days of the week as a list (of datetime.date objects)""" monday = self.day(0) return [monday + timedelta(days=i) for i in range(7)] def contains(self, day): """Check if the given datetime.date falls within the week""" return self.day(0) <= day < self.day(7) def toordinal(self): """Return the proleptic Gregorian ordinal the week, where January 1 of year 1 starts the first week.""" return self.monday().toordinal() // 7 + 1 def replace(self, year=None, week=None): """Return a Week with either the year or week attribute value replaced""" return self.__class__(self.year if year is None else year, self.week if week is None else week) def year_week(self): """Return a regular tuple containing the (year, week)""" return self.year, self.week def __str__(self): """Return a ISO formatted week string like "2011W08". """ return '%04dW%02d' % self isoformat = __str__ # compatibility with datetime.date def __repr__(self): """Return a string like "isoweek.Week(2011, 35)".""" return __name__ + '.' + self.__class__.__name__ + '(%d, %d)' % self def __add__(self, other): """Adding integers to a Week gives the week that many number of weeks into the future. Adding with datetime.timedelta is also supported. """ if isinstance(other, timedelta): other = other.days // 7 return self.__class__.fromordinal(self.toordinal() + other) def __sub__(self, other): """Subtracting two weeks give the number of weeks between them as an integer. Subtracting an integer gives another Week in the past.""" if isinstance(other, (int, long, timedelta)): return self.__add__(-other) return self.toordinal() - other.toordinal() Week.min = Week(1,1) Week.max = Week(9999,52) Week.resolution = timedelta(weeks=1) isoweek-1.3.3/isoweek.egg-info/0000755000175000017500000000000013033210716014422 5ustar hlehleisoweek-1.3.3/isoweek.egg-info/top_level.txt0000644000175000017500000000001013033210716017143 0ustar hlehleisoweek isoweek-1.3.3/isoweek.egg-info/dependency_links.txt0000644000175000017500000000000113033210716020470 0ustar hlehle isoweek-1.3.3/isoweek.egg-info/SOURCES.txt0000644000175000017500000000033013033210716016302 0ustar hlehleCHANGES.txt LICENSE.txt MANIFEST.in README.rst isoweek.py setup.cfg setup.py test_isoweek.py isoweek.egg-info/PKG-INFO isoweek.egg-info/SOURCES.txt isoweek.egg-info/dependency_links.txt isoweek.egg-info/top_level.txtisoweek-1.3.3/isoweek.egg-info/PKG-INFO0000644000175000017500000001233613033210716015524 0ustar hlehleMetadata-Version: 1.1 Name: isoweek Version: 1.3.3 Summary: Objects representing a week Home-page: http://github.com/gisle/isoweek Author: Gisle Aas Author-email: gisle@aas.no License: BSD Description: ISO Week ======== The isoweek module provide the class *Week*. Instances represent specific weeks spanning Monday to Sunday. There are 52 or 53 numbered weeks in a year. Week 1 is defined to be the first week with 4 or more days in January. It's called isoweek because this is the week definition of ISO 8601. This standard also define a notation for identifying weeks; yyyyWww (where the "W" is a literal). An example is "2011W08" which denotes the 8th week of year 2011. *Week* instances stringify to this form. See also http://en.wikipedia.org/wiki/ISO_week_date The *Week* instances are light weight and immutable with an interface similar to the datetime.date objects. Example code:: from isoweek import Week w = Week(2011, 20) print "Week %s starts on %s" % (w, w.monday()) print "Current week number is", Week.thisweek().week print "Next week is", Week.thisweek() + 1 Reference ---------- Constructor: *class* isoweek.Week(*year*, *week*) All arguments are required. Arguments should be ints. If the week number isn't within the range of the given year, the year is adjusted to make week number within range. The final year must be within range 1 to 9999. If not ValueError is raised. Other constructors, all class methods: *classmethod* Week.thisweek() Return the current week (local time). *classmethod* Week.fromordinal(*ordinal*) Return the week corresponding to the proleptic Gregorian ordinal, where January 1 of year 1 starts the week with ordinal 1. *classmethod* Week.fromstring(*isostring*) Return a week initialized from an ISO formatted string like "2011W08" or "2011-W08". Note that weeks always stringify back in the former and more compact format. *classmethod* Week.withdate(*date*) Return the week that contains the given datetime.date. *classmethod* Week.weeks_of_year(*year*) Return an iterator over the weeks of the given year. *classmethod* Week.last_week_of_year(*year*) Return the last week of the given year. Instance attributes (read-only): Week.year Between 1 and 9999 inclusive. Week.week Between 1 and 53 inclusive (52 for most years). Supported operations: ==================== ========================================================== Operation Result ==================== ========================================================== week1 = week2 + int week2 is int weeks removed from week1. week1 = week2 - int Computes week2 such that week2 + int == week1 int = week1 - week2 Computes int such that week2 + int == week1 week1 < week2 week1 is considered less than week2 when week1 precedes week2 in time. ==================== ========================================================== Instance methods: Week.replace(*year*, *week*) Return a Week with the same value, except for those parameters given new values by whichever keyword arguments are specified. Week.toordinal() Return the proleptic Gregorian ordinal the week, where January 1 of year 1 starts the first week. Week.day(*num*) Return the given day of week as a datetime.date object. Day 0 is Monday. Week.monday(), Week.tuesday(),.. Week.sunday() Return the given day of week as a datetime.date object. Week.days() Return the 7 days of the week as a list. Week.contains(day) Check if the given datetime.date falls within the week. Week.isoformat() Return a string representing the week in ISO 8601 format; "yyyyWww". For example Week(2011, 8).isoformat() == '2011W08'. Week.__str__() For a Week w, str(w) is equivalent to w.isoformat() Week.__repr__() Return a string like "isoweek.Week(2011, 2)". Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: BSD License Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Topic :: Software Development :: Libraries :: Python Modules isoweek-1.3.3/test_isoweek.py0000644000175000017500000001304413033201271014337 0ustar hlehleimport sys import unittest from isoweek import Week class TestWeek(unittest.TestCase): def test_constructors(self): w = Week(2011,1) self.assertTrue(w) self.assertEqual(str(w), "2011W01") w = Week(2011,0) self.assertEqual(str(w), "2010W52") w = Week(2011,-1) self.assertEqual(str(w), "2010W51") w = Week(2011,52) self.assertEqual(str(w), "2011W52") w = Week(2011,53) self.assertEqual(str(w), "2012W01") w = Week(2011,54) self.assertEqual(str(w), "2012W02") w = Week(2009,51) self.assertEqual(str(w), "2009W51") w = Week(2009,52) self.assertEqual(str(w), "2009W52") w = Week(2009,53) self.assertEqual(str(w), "2009W53") w = Week(2009,54) self.assertEqual(str(w), "2010W01") w = Week.thisweek() self.assertTrue(w) w = Week.fromordinal(1) self.assertEqual(str(w), "0001W01") w = Week.fromordinal(2) self.assertEqual(str(w), "0001W02") w = Week.fromordinal(521723) self.assertEqual(str(w), "9999W52") w = Week.fromstring("2011W01") self.assertEqual(str(w), "2011W01") w = Week.fromstring("2011-W01") self.assertEqual(str(w), "2011W01") from datetime import date w = Week.withdate(date(2011, 5, 17)) self.assertEqual(str(w), "2011W20") weeks = list(Week.weeks_of_year(2009)) self.assertEqual(len(weeks), 53) self.assertEqual(weeks[0], Week(2009,1)) self.assertEqual(weeks[-1], Week(2009,53)) weeks = list(Week.weeks_of_year(2011)) self.assertEqual(len(weeks), 52) self.assertEqual(weeks[0], Week(2011,1)) self.assertEqual(weeks[-1], Week(2011,52)) self.assertEqual(Week.last_week_of_year(2009), Week(2009, 53)) self.assertEqual(Week.last_week_of_year(2010), Week(2010, 52)) self.assertEqual(Week.last_week_of_year(2011), Week(2011, 52)) self.assertEqual(Week.last_week_of_year(9999), Week(9999, 52)) self.assertRaises(ValueError, lambda: Week(0, 0)) self.assertRaises(ValueError, lambda: Week.fromstring("0000W00")) self.assertRaises(ValueError, lambda: Week.fromstring("foo")) self.assertRaises(ValueError, lambda: Week.fromordinal(-1)) self.assertRaises(ValueError, lambda: Week.fromordinal(0)) self.assertRaises(ValueError, lambda: Week.fromordinal(521724)) self.assertRaises(ValueError, lambda: Week.last_week_of_year(0)) self.assertRaises(ValueError, lambda: Week.last_week_of_year(10000)) def test_mix_max(self): self.assertEqual(Week.min, Week(1,1)) self.assertEqual(Week.max, Week(9999,52)) self.assertEqual(Week.resolution.days, 7) self.assertRaises(ValueError, lambda: Week.min - 1) self.assertRaises(ValueError, lambda: Week.max + 1) def test_stringification(self): w = Week(2011, 20) self.assertEqual(str(w), "2011W20") self.assertEqual(w.isoformat(), "2011W20") self.assertEqual(repr(w), "isoweek.Week(2011, 20)") def test_replace(self): w = Week(2011, 20) self.assertEqual(w.replace(), w) self.assertEqual(w.replace(year=2010), Week(2010, 20)) self.assertEqual(w.replace(week=2), Week(2011, 2)) self.assertEqual(w.replace(week=99), Week(2012, 47)) self.assertEqual(w.replace(year=1, week=1), Week(1, 1)) def test_days(self): w = Week(2011, 20) self.assertEqual(w.monday().isoformat(), "2011-05-16") self.assertEqual(w.tuesday().isoformat(), "2011-05-17") self.assertEqual(w.wednesday().isoformat(), "2011-05-18") self.assertEqual(w.thursday().isoformat(), "2011-05-19") self.assertEqual(w.friday().isoformat(), "2011-05-20") self.assertEqual(w.saturday().isoformat(), "2011-05-21") self.assertEqual(w.sunday().isoformat(), "2011-05-22") self.assertEqual(w.day(0).isoformat(), "2011-05-16") self.assertEqual(w.day(-1).isoformat(), "2011-05-15") self.assertEqual(w.day(10).isoformat(), "2011-05-26") days = w.days() self.assertEqual(len(days), 7) self.assertEqual(days[0].isoformat(), "2011-05-16") self.assertEqual(days[-1].isoformat(), "2011-05-22") from datetime import date self.assertFalse(w.contains(date(2011,5,15))) self.assertTrue(w.contains(date(2011,5,16))) self.assertTrue(w.contains(date(2011,5,22))) self.assertFalse(w.contains(date(2011,5,23))) def test_arithmetics(self): w = Week(2011, 20) self.assertEqual(str(w + 0), "2011W20") self.assertEqual(str(w + 1), "2011W21") self.assertEqual(str(w - 1), "2011W19") if sys.version < '3': self.assertEqual(str(w + long(1)), "2011W21") self.assertEqual(str(w - long(1)), "2011W19") self.assertEqual(str(w + 52), "2012W20") self.assertEqual(str(w - 104), "2009W21") self.assertEqual(w - w, 0) self.assertEqual(w - Week(2011, 1), 19) self.assertEqual(Week(2011, 1) - w, -19) self.assertEqual(str(w + Week.resolution), "2011W21") self.assertEqual(str(w - Week.resolution), "2011W19") def test_arithmetics_subclass(self): class MyWeek(Week): pass w = MyWeek(2011, 20) next_week = w + 1 self.assertEqual(str(next_week), "2011W21") self.assertTrue(isinstance(next_week, MyWeek)) if __name__ == '__main__': unittest.main() isoweek-1.3.3/setup.py0000644000175000017500000000164213033210410012766 0ustar hlehleimport sys if sys.version_info < (2, 6, 0): print('You need Python 2.6 or better to install isoweek') sys.exit(1) from setuptools import setup setup( name = 'isoweek', version = '1.3.3', description = 'Objects representing a week', author='Gisle Aas', author_email='gisle@aas.no', url='http://github.com/gisle/isoweek', py_modules=['isoweek'], license='BSD', long_description=open("README.rst").read(), classifiers=[ 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', 'License :: OSI Approved :: BSD License', 'Operating System :: OS Independent', 'Programming Language :: Python', 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Topic :: Software Development :: Libraries :: Python Modules', ], ) isoweek-1.3.3/LICENSE.txt0000644000175000017500000000242113033201271013100 0ustar hlehleCopyright (c) 2011, Gisle Aas All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. isoweek-1.3.3/MANIFEST.in0000644000175000017500000000006413033201271013014 0ustar hlehleinclude *.rst include *.txt include test_isoweek.py isoweek-1.3.3/PKG-INFO0000644000175000017500000001233613033210716012364 0ustar hlehleMetadata-Version: 1.1 Name: isoweek Version: 1.3.3 Summary: Objects representing a week Home-page: http://github.com/gisle/isoweek Author: Gisle Aas Author-email: gisle@aas.no License: BSD Description: ISO Week ======== The isoweek module provide the class *Week*. Instances represent specific weeks spanning Monday to Sunday. There are 52 or 53 numbered weeks in a year. Week 1 is defined to be the first week with 4 or more days in January. It's called isoweek because this is the week definition of ISO 8601. This standard also define a notation for identifying weeks; yyyyWww (where the "W" is a literal). An example is "2011W08" which denotes the 8th week of year 2011. *Week* instances stringify to this form. See also http://en.wikipedia.org/wiki/ISO_week_date The *Week* instances are light weight and immutable with an interface similar to the datetime.date objects. Example code:: from isoweek import Week w = Week(2011, 20) print "Week %s starts on %s" % (w, w.monday()) print "Current week number is", Week.thisweek().week print "Next week is", Week.thisweek() + 1 Reference ---------- Constructor: *class* isoweek.Week(*year*, *week*) All arguments are required. Arguments should be ints. If the week number isn't within the range of the given year, the year is adjusted to make week number within range. The final year must be within range 1 to 9999. If not ValueError is raised. Other constructors, all class methods: *classmethod* Week.thisweek() Return the current week (local time). *classmethod* Week.fromordinal(*ordinal*) Return the week corresponding to the proleptic Gregorian ordinal, where January 1 of year 1 starts the week with ordinal 1. *classmethod* Week.fromstring(*isostring*) Return a week initialized from an ISO formatted string like "2011W08" or "2011-W08". Note that weeks always stringify back in the former and more compact format. *classmethod* Week.withdate(*date*) Return the week that contains the given datetime.date. *classmethod* Week.weeks_of_year(*year*) Return an iterator over the weeks of the given year. *classmethod* Week.last_week_of_year(*year*) Return the last week of the given year. Instance attributes (read-only): Week.year Between 1 and 9999 inclusive. Week.week Between 1 and 53 inclusive (52 for most years). Supported operations: ==================== ========================================================== Operation Result ==================== ========================================================== week1 = week2 + int week2 is int weeks removed from week1. week1 = week2 - int Computes week2 such that week2 + int == week1 int = week1 - week2 Computes int such that week2 + int == week1 week1 < week2 week1 is considered less than week2 when week1 precedes week2 in time. ==================== ========================================================== Instance methods: Week.replace(*year*, *week*) Return a Week with the same value, except for those parameters given new values by whichever keyword arguments are specified. Week.toordinal() Return the proleptic Gregorian ordinal the week, where January 1 of year 1 starts the first week. Week.day(*num*) Return the given day of week as a datetime.date object. Day 0 is Monday. Week.monday(), Week.tuesday(),.. Week.sunday() Return the given day of week as a datetime.date object. Week.days() Return the 7 days of the week as a list. Week.contains(day) Check if the given datetime.date falls within the week. Week.isoformat() Return a string representing the week in ISO 8601 format; "yyyyWww". For example Week(2011, 8).isoformat() == '2011W08'. Week.__str__() For a Week w, str(w) is equivalent to w.isoformat() Week.__repr__() Return a string like "isoweek.Week(2011, 2)". Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: BSD License Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Topic :: Software Development :: Libraries :: Python Modules