def testtoDateTime( self ):
      converter = cvt.toDateTime

      s = "4-mar-2004 12:13:14.1234 ET"
      right = datetime.datetime( 2004, 3, 4, 12, 13, 14, 123400 )

      t = converter( right )
      self.assertEqual( right, t, "Incorrect conversion of an Epoch." )
      
      t = converter( right )
      self.assertEqual( right, t, "Incorrect conversion of a datetime." )

      right = datetime.datetime( 2004, 3, 4 )
      t = converter( datetime.date( 2004, 3, 4 ) )
      self.assertEqual( right, t, "Incorrect conversion of a date." )

      self.assertRaises( Exception, converter, None, name='value',
                   msg="None argument should be an error." )
      self.assertRaises( Exception, converter, "foo bar", name='value',
                   msg="String argument should be an error." )
      self.assertRaises( Exception, converter, [ 1, 2, 3 ], name='value',
                   msg="List argument should be an error." )

      # Try w/ allowNone
      t = converter( None, allowNone=True )
      self.assertEqual( None, t, "Incorrect conversion of None." )

#=======================================================================
Test the toDateTime converter.
dataset/ETHPy150Open nasa/mplStyle/mplStyle/types/convert/test/test_toDateTime.py/TesttoDateTime.testtoDateTime