예제 #1
0
파일: message.py 프로젝트: mbbui/Jminee
 def _build_date_header_string(self, date_value):
     """Gets the date_value (may be None, basestring, float or 
     datetime.datetime instance) and returns a valid date string as per 
     RFC 2822."""
     if isinstance(date_value, datetime):
         date_value = time.mktime(date_value.timetuple())
     if not isinstance(date_value, basestring):
         date_value = formatdate(date_value, localtime=True)
     return date_value
예제 #2
0
 def test_date_can_be_set_as_float(self):
     expected_date = datetime(2008, 12, 26, 12, 55)
     expected_time = time.mktime(expected_date.timetuple())
     self.message.date = expected_time
     msg = email.message_from_string(str(self.message))
     header_string = msg['Date']
     header_date = self._date_header_to_utc_datetime(header_string)
     self.assertEqual(self.localdate_to_utc(expected_date), header_date)
     expected_datestring = formatdate(expected_time, localtime=True)
     self.assertEqual(expected_datestring, header_string)
예제 #3
0
 def localdate_to_utc(self, localdate):
     local_epoch_seconds = time.mktime(localdate.timetuple())
     date_string = formatdate(local_epoch_seconds, localtime=True)
     return self._date_header_to_utc_datetime(date_string)