示例#1
0
文件: engine.py 项目: k3njiy/invenio
def get_data_for_definition_bibrec(column_name, recids_copy):
    '''Having a column_name and a list of recids, it returns a dictionary
    mapping each recids with its correspondig value from the column'''
    dict_column = {}
    for recid in recids_copy:
        creation_date = run_sql('SELECT %s from bibrec WHERE id = %%s' %column_name, (recid, ))[0][0]
        new_creation_date = datetime(creation_date.year,creation_date.month,creation_date.day, \
                                     creation_date.hour,creation_date.minute, creation_date.second)
        dict_column[recid] = new_creation_date.strftime('%Y%m%d%H%M%S')
    return dict_column
示例#2
0
def get_data_for_definition_bibrec(column_name, recids_copy):
    '''Having a column_name and a list of recids, it returns a dictionary
    mapping each recids with its correspondig value from the column'''
    dict_column = {}
    for recid in recids_copy:
        creation_date = run_sql(
            'SELECT %s from bibrec WHERE id = %%s' % column_name,
            (recid, ))[0][0]
        new_creation_date = datetime(creation_date.year,creation_date.month,creation_date.day, \
                                     creation_date.hour,creation_date.minute, creation_date.second)
        dict_column[recid] = new_creation_date.strftime('%Y%m%d%H%M%S')
    return dict_column
示例#3
0
 def test_datetime_date(self):
     expected = datetime.date(1987, 6, 5)
     dt = dateutils.datetime(1987, 6, 5, 4, 3, 2, 1, None)
     self.assertEqual(expected, dt.date())
示例#4
0
 def test_datetime_strftime_before_1900(self):
     new_datetime = dateutils.datetime(1765, 1, 3, 10, 2, 13)
     expected = "Thu, 03 Jan 1765 10:02:13 +0000"
     result = new_datetime.strftime("%a, %d %b %Y %H:%M:%S +0000")
     self.assertEqual(expected, result)
示例#5
0
 def test_datetime_creation_before_1900(self):
     expected = datetime.datetime(1765, 1, 3, 10, 2, 13)
     result = dateutils.datetime(1765, 1, 3, 10, 2, 13)
     self.assertEqual(expected, result)
示例#6
0
 def test_datetime_creation_after_1900(self):
     expected = datetime.datetime(1908, 3, 12, 12, 12, 12)
     result = dateutils.datetime(1908, 3, 12, 12, 12, 12)
     self.assertEqual(expected, result)
示例#7
0
 def test_datetime_date(self):
     expected = datetime.date(1987, 6, 5)
     dt = dateutils.datetime(1987, 6, 5, 4, 3, 2, 1, None)
     self.assertEqual(expected, dt.date())
示例#8
0
 def test_datetime_strftime_before_1900(self):
     new_datetime = dateutils.datetime(1765, 1, 3, 10, 2, 13)
     expected = "Thu, 03 Jan 1765 10:02:13 +0000"
     result = new_datetime.strftime("%a, %d %b %Y %H:%M:%S +0000")
     self.assertEqual(expected, result)
示例#9
0
 def test_datetime_creation_before_1900(self):
     expected = datetime.datetime(1765, 1, 3, 10, 2, 13)
     result = dateutils.datetime(1765, 1, 3, 10, 2, 13)
     self.assertEqual(expected, result)
示例#10
0
 def test_datetime_creation_after_1900(self):
     expected = datetime.datetime(1908, 3, 12, 12, 12, 12)
     result = dateutils.datetime(1908, 3, 12, 12, 12, 12)
     self.assertEqual(expected, result)