コード例 #1
0
 def test_to_ISO8601(self):
     unixtime = 1378459200
     iso = "2013-09-06 09:20:00+00:00"
     date = datetime(2013, 9, 6, 9, 20, 0, 0, timezone.utc)
     self.assertEqual(iso, formatting.to_ISO8601(unixtime))
     self.assertEqual(iso, formatting.to_ISO8601(iso))
     self.assertEqual(iso, formatting.to_ISO8601(date))
コード例 #2
0
ファイル: station.py プロジェクト: mohsen20100/pyowm
    def to_dict(self):
        """Dumps object to a dictionary

        :returns: a `dict`

        """
        return {
            'id': self.id,
            'external_id': self.external_id,
            'name': self.name,
            'created_at': formatting.to_ISO8601(self.created_at),
            'updated_at': formatting.to_ISO8601(self.updated_at),
            'latitude': self.lat,
            'longitude': self.lon,
            'altitude': self.alt if self.alt is not None else 'None',
            'rank': self.rank}
コード例 #3
0
    def test_creation_time(self):
        buf = Buffer(self.station_id)
        ts = buf.creation_time()
        iso_result = buf.creation_time(timeformat='iso')
        self.assertEqual(to_ISO8601(ts), iso_result)
        date_result = buf.creation_time(timeformat='date')
        self.assertEqual(to_date(ts), date_result)
        with self.assertRaises(ValueError):
            buf.creation_time(timeformat='unknown')

        buf.created_at = None
        self.assertIsNone(buf.creation_time())
コード例 #4
0
 def __repr__(self):
     return "<%s.%s - id=%s, trigger id=%s, last update=%s>" % (
         __name__, self.__class__.__name__, self.id, self.trigger_id,
         formatting.to_ISO8601(self.last_update))