How to use the pyowm.utils.timeformatutils.timeformat function in pyowm

To help you get started, we’ve selected a few pyowm examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github csparpa / pyowm / tests / unit / utils / test_timeformatutils.py View on Github external
def test_timeformat(self):
        unixtime = 1378459200
        iso = "2013-09-06 09:20:00+00"
        date = datetime(2013, 9, 6, 9, 20, 0, tzinfo=timeformatutils.UTC())
        self.assertEqual(unixtime, timeformatutils.timeformat(unixtime, "unix"))
        self.assertEqual(iso, timeformatutils.timeformat(unixtime, "iso"))
        self.assertEqual(date, timeformatutils.timeformat(unixtime, "date"))
        self.assertEqual(unixtime, timeformatutils.timeformat(iso, "unix"))
        self.assertEqual(iso, timeformatutils.timeformat(iso, "iso"))
        self.assertEqual(date, timeformatutils.timeformat(iso, "date"))
        self.assertEqual(unixtime, timeformatutils.timeformat(date, "unix"))
        self.assertEqual(iso, timeformatutils.timeformat(date, "iso"))
        self.assertEqual(date, timeformatutils.timeformat(date, "date"))
github csparpa / pyowm / tests / unit / utils / test_timeformatutils.py View on Github external
def test_timeformat(self):
        unixtime = 1378459200
        iso = "2013-09-06 09:20:00+00"
        date = datetime(2013, 9, 6, 9, 20, 0, tzinfo=timeformatutils.UTC())
        self.assertEqual(unixtime, timeformatutils.timeformat(unixtime, "unix"))
        self.assertEqual(iso, timeformatutils.timeformat(unixtime, "iso"))
        self.assertEqual(date, timeformatutils.timeformat(unixtime, "date"))
        self.assertEqual(unixtime, timeformatutils.timeformat(iso, "unix"))
        self.assertEqual(iso, timeformatutils.timeformat(iso, "iso"))
        self.assertEqual(date, timeformatutils.timeformat(iso, "date"))
        self.assertEqual(unixtime, timeformatutils.timeformat(date, "unix"))
        self.assertEqual(iso, timeformatutils.timeformat(date, "iso"))
        self.assertEqual(date, timeformatutils.timeformat(date, "date"))
github csparpa / pyowm / tests / unit / utils / test_timeformatutils.py View on Github external
def test_timeformat(self):
        unixtime = 1378459200
        iso = "2013-09-06 09:20:00+00"
        date = datetime(2013, 9, 6, 9, 20, 0, tzinfo=timeformatutils.UTC())
        self.assertEqual(unixtime, timeformatutils.timeformat(unixtime, "unix"))
        self.assertEqual(iso, timeformatutils.timeformat(unixtime, "iso"))
        self.assertEqual(date, timeformatutils.timeformat(unixtime, "date"))
        self.assertEqual(unixtime, timeformatutils.timeformat(iso, "unix"))
        self.assertEqual(iso, timeformatutils.timeformat(iso, "iso"))
        self.assertEqual(date, timeformatutils.timeformat(iso, "date"))
        self.assertEqual(unixtime, timeformatutils.timeformat(date, "unix"))
        self.assertEqual(iso, timeformatutils.timeformat(date, "iso"))
        self.assertEqual(date, timeformatutils.timeformat(date, "date"))
github csparpa / pyowm / pyowm / webapi25 / owm25.py View on Github external
boundary (defaults to ``None``, in which case the current datetime
            will be used)
        :type end: int, ``datetime.datetime`` or ISO8601-formatted string
        :return: a list of *UVIndex* instances or empty list if data is not available
        :raises: *ParseResponseException* when OWM web API responses' data
            cannot be parsed, *APICallException* when OWM web API can not be
            reached, *ValueError* for wrong input values
        """
        geo.assert_is_lon(lon)
        geo.assert_is_lat(lat)
        assert start is not None
        start = timeformatutils.timeformat(start, 'unix')
        if end is None:
            end = timeutils.now(timeformat='unix')
        else:
            end = timeformatutils.timeformat(end, 'unix')
        params = {'lon': lon, 'lat': lat, 'start': start, 'end': end}
        json_data = self._uvapi.get_uvi_history(params)
        uvindex_list = self._parsers['uvindex_list'].parse_JSON(json_data)
        return uvindex_list
github csparpa / pyowm / pyowm / webapi25 / weather.py View on Github external
def get_reference_time(self, timeformat='unix'):
        """Returns the GMT time telling when the weather was measured

        :param timeformat: the format for the time value. May be:
            '*unix*' (default) for UNIX time
            '*iso*' for ISO8601-formatted string in the format ``YYYY-MM-DD HH:MM:SS+00``
            '*date* for ``datetime.datetime`` object instance
        :type timeformat: str
        :returns: an int or a str
        :raises: ValueError when negative values are provided

        """
        return timeformatutils.timeformat(self._reference_time, timeformat)
github csparpa / pyowm / pyowm / webapi25 / uvindex.py View on Github external
def get_reference_time(self, timeformat='unix'):
        """
        Returns the GMT time telling when the UV has been observed
          from the OWM web API

        :param timeformat: the format for the time value. May be:
            '*unix*' (default) for UNIX time
            '*iso*' for ISO8601-formatted string in the format ``YYYY-MM-DD HH:MM:SS+00``
            '*date* for ``datetime.datetime`` object instance
        :type timeformat: str
        :returns: an int or a str
        :raises: ValueError when negative values are provided

        """
        return timeformatutils.timeformat(self._reference_time, timeformat)