コード例 #1
0
    def set_leading_zero_date_without_divider(self):
        date_record = self.get_date_record()

        if len(date_record) == 4:
            if int(date_record[0:2]) > 12:
                date_record = '0' + date_record[0] + '0' + date_record[
                    1] + date_record[2:len(date_record)]
            self.__date_record = date_record

        elif len(date_record) in [5, 7]:
            result = None
            if len(date_record) == 5:
                result = DaguHelper.try_month_year_wd_len_5(date_record)
            elif len(date_record) == 7:
                result = DaguHelper.try_month_year_wd_len_7(date_record)

            if result is None:
                if int(date_record[0]) == 0:
                    date_record = date_record[0:2] + '0' + date_record[
                        2:len(date_record)]
                    self.__date_record = date_record

                else:
                    date_record = '0' + date_record
                    self.__date_record = date_record

        elif len(date_record) == 6:
            result = DaguHelper.try_day_month_year(date_record)
            if result is None:
                date_record = '0' + date_record[0] + '0' + date_record[
                    1] + date_record[2:len(date_record)]
                self.__date_record = date_record
コード例 #2
0
    def set_leading_zero_date_with_divider(self):
        date_record = self.get_date_record()
        divider = self.get_divider()

        if len(date_record[0:date_record.find(divider)]) < 2:
            date_record = '0' + date_record
            self.__date_record = date_record

        position = DaguHelper.findnth(record=date_record, n=2, divider=divider)
        if len(date_record[3:position]) < 2:
            date_record = date_record[0:3] + "0" + date_record[
                3:len(date_record)]
            self.__date_record = date_record
コード例 #3
0
    def match_date(self, date_options, divider):
        """
        :param date_options: A list of possible date options identified for this record.
        :param divider: All date options should still need formatting do be done in two places. The divider is inserted
        in the open spots.
        :param record: A stringified datetime object.
        :return: Returns a datetime object.
        """

        if len(date_options) == 0:
            return None

        record = self.get_record()
        for date_option in date_options:
            result = DaguHelper.try_date_option(date_option=date_option,
                                                divider=divider,
                                                record=record)
            if result is not None:
                return result
        return None
コード例 #4
0
    def set_length(self):
        """
            In order to determine possible matching datetime objects, a list should be selected from the config file.
            This is done based on the length of the record, excluding dividers.
        """

        record = self.get_record()
        divider = self.get_divider()
        timestamp_record, date_record = DaguHelper.split_record(record=record)

        if divider == '':
            record_length = len(record)
        else:
            count = date_record.count(divider)
            if count > 2:
                raise ValueError('A date should only contain two dividers.')

            record_length = len(record) - count
            # print(len(record))

        self.__length = record_length
コード例 #5
0
 def set_divider(self, record):
     timestamp_record, date_record = DaguHelper.split_record(record=record)
     divider = DaguHelper.get_divider(record=date_record)
     self.__divider = divider
コード例 #6
0
 def set_leading_zero_alpha(self):
     date_record = self.get_date_record()
     date_record = DaguHelper.numeric_in_alpha(record=date_record)
     self.__date_record = date_record
コード例 #7
0
 def set_alpha_check(self):
     date_record = self.get_date_record()
     alpha_check = DaguHelper.alpha_check(record=date_record)
     self.__alpha_check = alpha_check
コード例 #8
0
 def split_record(self):
     record = self.get_record()
     timestamp_record, date_record = DaguHelper.split_record(record=record)
     self.__timestamp_record = timestamp_record
     self.__date_record = date_record