# Path: pytrainer/platform.py
# def get_platform():
#     if os.name == "posix":
#         return _Linux() #although not true, not changing original return name to avoid side effects
#     elif os.name == "nt":
#         return _Windows()
#     else:
#         logging.critical("Unsupported os.name: %s.", os.name)
#         sys.exit(1)
# 
# Path: pytrainer/lib/localization.py
# def locale_str(string):
#     if sys.version_info[0] == 2:
#         lcname, encoding=locale.getlocale()
#         return string.decode(encoding)
#     else:
#         return string


import time
import datetime
import calendar
import dateutil.parser
import logging
from dateutil.tz import tzutc, tzlocal
from pytrainer.platform import get_platform
from pytrainer.lib.localization import locale_str
            raise TypeError("End date must be datetime.date, not {0}.".format(type(start_date).__name__))
        if start_date > end_date:
            raise ValueError("End date cannot be before start date.")
        self._start_date = start_date
        self._end_date = end_date

    @property
    def start_date(self):
        return self._start_date

    @property
    def end_date(self):
        return self._end_date

    def __str__(self):
        fmt = "%Y%m%d"
        return self._start_date.strftime(fmt) + "-" + self._end_date.strftime(fmt)

    @classmethod
    def for_week_containing(clazz, date):
        """Get the date range for the week containing the given date.

        The date range will start on the first day of the week and end on the
        last day of the week. The week start and end days are locale dependent.

        Args:
            date (datetime.date): a date within the week to get the date range for.
        Returns:
            (DateRange): the date range for a week.
        """

# Path: pytrainer/platform.py
# def get_platform():
#     if os.name == "posix":
#         return _Linux() #although not true, not changing original return name to avoid side effects
#     elif os.name == "nt":
#         return _Windows()
#     else:
#         logging.critical("Unsupported os.name: %s.", os.name)
#         sys.exit(1)
# 
# Path: pytrainer/lib/localization.py
# def locale_str(string):
#     if sys.version_info[0] == 2:
#         lcname, encoding=locale.getlocale()
#         return string.decode(encoding)
#     else:
#         return string


# Path: pytrainer/lib/date.py
import time
import datetime
import calendar
import dateutil.parser
import logging
from dateutil.tz import tzutc, tzlocal
from pytrainer.platform import get_platform
from pytrainer.lib.localization import locale_str

            raise TypeError("End date must be datetime.date, not {0}.".format(type(start_date).__name__))
        if start_date > end_date:
            raise ValueError("End date cannot be before start date.")
        self._start_date = start_date
        self._end_date = end_date

    @property
    def start_date(self):
        return self._start_date

    @property
    def end_date(self):
        return self._end_date

    def __str__(self):
        fmt = "%Y%m%d"
        return self._start_date.strftime(fmt) + "-" + self._end_date.strftime(fmt)

    @classmethod
    def for_week_containing(clazz, date):
        """Get the date range for the week containing the given date.

        The date range will start on the first day of the week and end on the
        last day of the week. The week start and end days are locale dependent.

        Args:
            date (datetime.date): a date within the week to get the date range for.
        Returns:
            (DateRange): the date range for a week.
        """

        day_of_week = (int(date.strftime("%w")) - get_platform().get_first_day_of_week()) % 7