Пример #1
0
 def test_date2ymdh(self):
     """Test date2ymdh function"""
     year, month, day, hour, minute, dt = loadData.date2ymdh(self.goodInputDates)
     assert_almost_equal(year, self.outputYear)
     assert_almost_equal(month, self.outputMonth)
     assert_almost_equal(day, self.outputDay)
     assert_almost_equal(hour, self.outputHour)
     assert_almost_equal(minute, self.outputMinute)
Пример #2
0
 def test_date2ymdh(self):
     """Test date2ymdh function"""
     year, month, day, hour, minute, dt = loadData.date2ymdh(
         self.goodInputDates)
     assert_almost_equal(year, self.outputYear)
     assert_almost_equal(month, self.outputMonth)
     assert_almost_equal(day, self.outputDay)
     assert_almost_equal(hour, self.outputHour)
     assert_almost_equal(minute, self.outputMinute)
Пример #3
0
    def test_date2ymdhFormats(self):
        """Test date2ymdh with different input date formats"""

        formats = [
            '%Y-%m-%d %H:%M:%S', '%Y%m%dT%H%M', '%H:%M %d/%m/%Y',
            '%H:%M %m/%d/%Y', '%I:%M %p %d/%m/%Y'
        ]
        for fmt in formats:
            dates = []
            for d in self.goodInputDates:
                dtobj = datetime.strptime(d, self.dateformat)
                datestr = dtobj.strftime(fmt)
                dates.append(datestr)
            year, month, day, hour, minute, dt = loadData.date2ymdh(dates, fmt)
            assert_almost_equal(self.outputYear, year)
            assert_almost_equal(self.outputMonth, month)
            assert_almost_equal(self.outputDay, day)
            assert_almost_equal(self.outputHour, hour)
            assert_almost_equal(self.outputMinute, minute)
Пример #4
0
    def test_date2ymdhFormats(self):
        """Test date2ymdh with different input date formats"""

        formats = ['%Y-%m-%d %H:%M:%S',
                   '%Y%m%dT%H%M',
                   '%H:%M %d/%m/%Y',
                   '%H:%M %m/%d/%Y',
                   '%I:%M %p %d/%m/%Y']
        for fmt in formats:
            dates = []
            for d in self.goodInputDates:
                dtobj = datetime.strptime(d, self.dateformat)
                datestr = dtobj.strftime(fmt)
                dates.append(datestr)
            year, month, day, hour, minute, dt = loadData.date2ymdh(dates, fmt)
            assert_almost_equal(self.outputYear, year)
            assert_almost_equal(self.outputMonth, month)
            assert_almost_equal(self.outputDay, day)
            assert_almost_equal(self.outputHour, hour)
            assert_almost_equal(self.outputMinute, minute)