本文整理汇总了Python中pyowm.utils.timeformatutils.timeformat函数的典型用法代码示例。如果您正苦于以下问题:Python timeformat函数的具体用法?Python timeformat怎么用?Python timeformat使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了timeformat函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, id, created_at, updated_at, external_id, name,
lon, lat, alt, rank):
assert id is not None
assert external_id is not None
assert lon is not None
assert lat is not None
if lon < -180.0 or lon > 180.0:
raise ValueError("'lon' value must be between -180 and 180")
self._lon = float(lon)
if lat < -90.0 or lat > 90.0:
raise ValueError("'lat' value must be between -90 and 90")
if alt is not None:
if alt < 0.0:
raise ValueError("'alt' value must not be negative")
self.id = id
self.created_at = created_at
if self.created_at is not None:
padded_created_at = self._format_micros(created_at)
t = dt.strptime(padded_created_at,
'%Y-%m-%dT%H:%M:%S.%fZ').replace(
tzinfo=timeformatutils.UTC())
self.created_at = timeformatutils.timeformat(t, 'unix')
self.updated_at = updated_at
if self.updated_at is not None:
padded_updated_at = self._format_micros(updated_at)
t = dt.strptime(padded_updated_at,
'%Y-%m-%dT%H:%M:%S.%fZ').replace(
tzinfo=timeformatutils.UTC())
self.updated_at = timeformatutils.timeformat(t, 'unix')
self.external_id = external_id
self.name = name
self.lon = lon
self.lat = lat
self.alt = alt
self.rank = rank
开发者ID:AlerzDev,项目名称:Brazo-Proyecto-Final,代码行数:35,代码来源:station.py
示例2: to_entity
def to_entity(self):
"""
Generates a UVIndex object out of the current model
:return: a pyowm.webapi25.uvindex.UVIndex instance
"""
return UVIndexEntity(
timeformatutils.timeformat(self.reference_time, 'unix'),
Location.to_entity(self.location),
self.interval,
self.value,
timeformatutils.timeformat(self.reception_time, 'unix'))
开发者ID:csparpa,项目名称:django-pyowm,代码行数:11,代码来源:models.py
示例3: test_timeformat
def test_timeformat(self):
unixtime = 1378459200
iso = "2013-09-06 09:20:00+00"
date = datetime(2013, 9, 6, 9, 20, 0)
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"))
开发者ID:maroffo,项目名称:pyowm,代码行数:13,代码来源:test_timeformatutils.py
示例4: get_reference_time
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 or '*iso*' for ISO8601-formatted
string in the format ``YYYY-MM-DD HH:MM:SS+00``
:type timeformat: str
:returns: an int or a str
:raises: ValueError when negative values are provided
"""
return timeformatutils.timeformat(self._reference_time, timeformat)
开发者ID:FailSafe86,项目名称:pyowm,代码行数:12,代码来源:weather.py
示例5: get_sunrise_time
def get_sunrise_time(self, timeformat='unix'):
"""Returns the GMT time of sunrise
:param timeformat: the format for the time value. May be:
'*unix*' (default) for UNIX time or '*iso*' for ISO8601-formatted
string in the format ``YYYY-MM-DD HH:MM:SS+00``
:type timeformat: str
:returns: an int or a str
:raises: ValueError
"""
return timeformatutils.timeformat(self._sunrise_time, timeformat)
开发者ID:Henkiebob,项目名称:fietsbot,代码行数:12,代码来源:weather.py
示例6: downloaded_on
def downloaded_on(self, timeformat='unix'):
"""Returns the UTC time telling when the satellite image was downloaded from the OWM Agro 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
"""
return timeformatutils.timeformat(self._downloaded_on, timeformat)
开发者ID:csparpa,项目名称:pyowm,代码行数:12,代码来源:imagery.py
示例7: acquisition_time
def acquisition_time(self, timeformat='unix'):
"""Returns the UTC time telling when the image data was acquired by the satellite
: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
"""
return timeformatutils.timeformat(self._acquisition_time, timeformat)
开发者ID:csparpa,项目名称:pyowm,代码行数:12,代码来源:imagery.py
示例8: get_reception_time
def get_reception_time(self, timeformat='unix'):
"""Returns the GMT time telling when the meteostation history data was
received from the OWM web API
:param timeformat: the format for the time value. May be:
'*unix*' (default) for UNIX time or '*iso*' for ISO8601-formatted
string in the format ``YYYY-MM-DD HH:MM:SS+00``
:type timeformat: str
:returns: an int or a str
:raises: ValueError
"""
return timeformatutils.timeformat(self._reception_time, timeformat)
开发者ID:maroffo,项目名称:pyowm,代码行数:13,代码来源:stationhistory.py
示例9: now
def now(timeformat='date'):
"""
Returns the current time in the specified timeformat.
:param timeformat: the target format for the time conversion. May be:
'*date*' (default - outputs a ``datetime.datetime`` object), '*unix*'
(outputs a long UNIXtime) or '*iso*' (outputs an ISO8601-formatted
string with pattern ``YYYY-MM-DD HH:MM:SS+00``)
:type timeformat: str
:returns: the current time value
:raises: ValueError when unknown timeformat switches are provided or
when negative time values are provided
"""
return timeformatutils.timeformat(datetime.now(), timeformat)
开发者ID:maroffo,项目名称:pyowm,代码行数:14,代码来源:timeutils.py
示例10: get_reference_time
def get_reference_time(self, timeformat='unix'):
"""
Returns the GMT time telling when the CO samples have been 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)
开发者ID:csparpa,项目名称:pyowm,代码行数:14,代码来源:coindex.py
示例11: get_reception_time
def get_reception_time(self, timeformat='unix'):
"""Returns the GMT time telling when the forecast was received
from the OWM Weather 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
"""
return timeformatutils.timeformat(self._reception_time, timeformat)
开发者ID:csparpa,项目名称:pyowm,代码行数:14,代码来源:forecast.py
示例12: last_update_time
def last_update_time(self, timeformat='unix'):
"""Returns the UTC time of the last update on this station's metadata
: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`` or `date` for
a ``datetime.datetime`` object
:type timeformat: str
:returns: an int or a str or a ``datetime.datetime`` object or None
:raises: ValueError
"""
if self.updated_at is None:
return None
return timeformatutils.timeformat(self.updated_at, timeformat)
开发者ID:AlerzDev,项目名称:Brazo-Proyecto-Final,代码行数:15,代码来源:station.py
示例13: creation_time
def creation_time(self, timeformat='unix'):
"""Returns the UTC time of creation of this aggregated measurement
: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`` or `date` for
a ``datetime.datetime`` object
:type timeformat: str
:returns: an int or a str or a ``datetime.datetime`` object or None
:raises: ValueError
"""
if self.timestamp is None:
return None
return timeformatutils.timeformat(self.timestamp, timeformat)
开发者ID:AlerzDev,项目名称:Brazo-Proyecto-Final,代码行数:15,代码来源:measurement.py
示例14: when_ends
def when_ends(self, timeformat='unix'):
"""
Returns the GMT time of the end of the forecast coverage, which is the
time of the most recent *Weather* item in the forecast
:param timeformat: the format for the time value. May be:
'*unix*' (default) for UNIX time or '*iso*' for ISO8601-formatted
string in the format ``YYYY-MM-DD HH:MM:SS+00``
:type timeformat: str
:returns: a long or a str
:raises: *ValueError* when invalid time format values are provided
"""
end_coverage = max([item.get_reference_time() \
for item in self._forecast])
return timeformatutils.timeformat(end_coverage, timeformat)
开发者ID:FailSafe86,项目名称:pyowm,代码行数:16,代码来源:forecaster.py
示例15: when_starts
def when_starts(self, timeformat='unix'):
"""
Returns the GMT time of the start of the forecast coverage, which is
the time of the most ancient *Weather* item in the forecast
: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: a long or a str
:raises: *ValueError* when invalid time format values are provided
"""
start_coverage = min([item.get_reference_time() \
for item in self._forecast])
return timeformatutils.timeformat(start_coverage, timeformat)
开发者ID:csparpa,项目名称:pyowm,代码行数:17,代码来源:forecaster.py
注:本文中的pyowm.utils.timeformatutils.timeformat函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论