Esempio n. 1
0
 def test_timenow(self):
     
     time='20121023401223'
     
     time_set=datetime.format_timedata(time)
     
     self.assertFalse(datetime.checkdatetime(time_set[0], time_set[1], time_set[2], time_set[3], time_set[4], time_set[5]))
     
     time='20121126231248'
     
     time_set=datetime.format_timedata(time)
     
     self.assertTrue(datetime.checkdatetime(time_set[0], time_set[1], time_set[2], time_set[3], time_set[4], time_set[5]))
     
     timestamp=datetime.obtain_timestamp(time)
     
     self.assertTrue(timestamp)
     
     datetime.timezone='Europe/Madrid'
     
     datetime.set_timezone()
     
     # Check conversions to gmt time
     
     gmtstamp=datetime.local_to_gmt(time)
     
     self.assertEqual(gmtstamp, '20121126221248')
     
     time_from_utc=datetime.format_time(time)
     
     self.assertEqual(time_from_utc, '00:12:48')
     
     date_from_utc=datetime.format_date(time)
     
     self.assertEqual(date_from_utc, '2012/11/27')
     
     time_summer='20120826231248'
     
     gmtstamp=datetime.local_to_gmt(time_summer)
     
     self.assertEqual(gmtstamp, '20120826211248')
     
     #today=datetime.now()
     
     #print(today)
     
     """
Esempio n. 2
0
 def check(self, value):
     
     value=datetime.local_to_gmt(value)
     
     if value==False:
         
         self.error=True
         self.txt_error='Date format invalid'
         return ''
     
     return value