ZeevG / python-forecast.io

A thin Python Wrapper for the Dark Sky (formerly forecast.io) weather API
http://zeevgilovitz.com/python-forecast.io/
Other
424 stars 88 forks source link

Time error #28

Closed hugo-pires closed 9 years ago

hugo-pires commented 9 years ago

Hello

When I make a load forecast like this

api_key = "xxxx"
lat = xxxx
lng = xxxx
time = "2015-01-06 12:00:00"
forecast = forecastio.load_forecast(api_key, lat, lng, time)

python returns the following error

'str' object has no attribute 'timetuple'

Could you help me?

ZeevG commented 9 years ago

Hi, the time parameter needs to be a Python datetime object.

For example

import datetime

api_key = "xxxx"
lat = xxxx
lng = xxxx
time = datetime.datetime(2015, 01, 06, 12, 0)
forecast = forecastio.load_forecast(api_key, lat, lng, time)

You can read up on datetime objects here https://docs.python.org/2/library/datetime.html#datetime-objects