Skip to content
This repository was archived by the owner on Aug 4, 2020. It is now read-only.

[docs] Advise everyone to use datetime.utcnow() #19

Merged
merged 1 commit into from
Jul 5, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ We only create one datastream at a time.
Datapoints
----------

>>> now = datetime.now()
>>> now = datetime.utcnow()
>>> datapoints = datastream.datapoints.create([
... {'at': now - timedelta(seconds=1), 'value': 42},
... {'at': now, 'value': 43},
Expand All @@ -44,15 +44,15 @@ Historical Queries

Fetching history of a datastream:

>>> datapoints = datastream.datapoints.history(end=datetime.now(), duration=1800)
>>> datapoints = datastream.datapoints.history(end=datetime.utcnow(), duration=1800)

Retrieving a datastream with historical datapoints:

>>> datastream = feed.datastreams.get("energy", end=datetime.now(), duration="30minutes")
>>> datastream = feed.datastreams.get("energy", end=datetime.utcnow(), duration="30minutes")
>>> datapoints = list(datastream.datapoints)

Retrieving a feed and its datastreams with historical datapoints:

>>> feed = client.feeds.get(feed.id, end=datetime.now(), duration=3600, datastreams=[...])
>>> feed = client.feeds.get(feed.id, end=datetime.utcnow(), duration=3600, datastreams=[...])
>>> print list(feed.datastreams[0].datapoints)
[Datapoint(...), Datapoint(...), ...]
8 changes: 4 additions & 4 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Example:

>>> # Updating a feed
>>> import datetime
>>> now = datetime.datetime.now()
>>> now = datetime.datetime.utcnow()
>>> feed.datastreams = [
... xively.Datastream(id='sensor1', current_value=37.2, at=now),
... xively.Datastream(id='sensor2', current_value='normal', at=now),
Expand All @@ -39,9 +39,9 @@ Example:
>>> # Uploading new points
>>> import random
>>> randompoints = [
... xively.Datapoint(datetime.datetime.now(), random.random()),
... xively.Datapoint(datetime.datetime.now(), random.random()),
... xively.Datapoint(datetime.datetime.now(), random.random()),
... xively.Datapoint(datetime.datetime.utcnow(), random.random()),
... xively.Datapoint(datetime.datetime.utcnow(), random.random()),
... xively.Datapoint(datetime.datetime.utcnow(), random.random()),
... ]
>>> stream.datapoints = randompoints
>>> stream.update(fields='datapoints')
Expand Down