Пример #1
0
    def get_start_and_end_date(self, dates):
        """
        Get a tuple with start and end dates. Default is none for end date, and last week-day for start_date

        :param dates:list of dates
        :return:tuple (start,end)
        """
        date_objects = [dateutil.parser.parse(d, dayfirst=True) for d in dates]

        # default values is None for end_date and last week-day for start_date
        start_date = None
        end_date = None
        if date_objects is None or len(date_objects) == 0:
            date_objects.append(DateHelper.get_last_week_day())

        if len(date_objects) == 1:
            start_date = ZebraHelper.zebra_date(date_objects[0])
        if len(date_objects) == 2:
            start_date = ZebraHelper.zebra_date(min(date_objects))
            end_date = ZebraHelper.zebra_date(max(date_objects))

        return (start_date, end_date)
Пример #2
0
    def get_start_and_end_date(self, dates):
        """
        Get a tuple with start and end dates. Default is none for end date, and last week-day for start_date

        :param dates:list of dates
        :return:tuple (start,end)
        """
        date_objects = [dateutil.parser.parse(d, dayfirst=True) for d in dates]

        # default values is None for end_date and last week-day for start_date
        start_date = None
        end_date = None
        if date_objects is None or len(date_objects) == 0:
            date_objects.append(DateHelper.get_last_week_day())

        if len(date_objects) == 1:
            start_date = ZebraHelper.zebra_date(date_objects[0])
        if len(date_objects) == 2:
            start_date = ZebraHelper.zebra_date(min(date_objects))
            end_date = ZebraHelper.zebra_date(max(date_objects))

        return (start_date, end_date)
Пример #3
0
 def testStartAndEndDates(self):
     """should return a tuple with start and end dates as zebra dates"""
     base_command = BaseCommand()
     self.assertEquals(
         ('2013-05-22', None),
         base_command.get_start_and_end_date(['2013.05.22']),
         'test input format 1'
     )
     self.assertEquals(
         ('2013-05-22', None),
         base_command.get_start_and_end_date(['22.05.2013']),
         'test input format 2'
     )
     self.assertNotEquals(
         (None, None),
         base_command.get_start_and_end_date([]),
         'if no date is specified, date_start should not be None'
     )
     last_week_day = ZebraHelper.zebra_date(DateHelper.get_last_week_day())
     self.assertEquals(
         (last_week_day, None),
         base_command.get_start_and_end_date([]),
         'if no date is specified, date_start should be last week day'
     )
Пример #4
0
 def testZebraDate(self):
     """date format is correct"""
     date = datetime.datetime.strptime('20130428', "%Y%m%d").date()
     self.assertEquals('2013-04-28', ZebraHelper.zebra_date(date))
Пример #5
0
 def testZebraDate(self):
     """date format is correct"""
     date = datetime.datetime.strptime('20130428', "%Y%m%d").date()
     self.assertEquals('2013-04-28', ZebraHelper.zebra_date(date))