Skip to content

Commit

Permalink
Fix compatibility with aw-server-rust
Browse files Browse the repository at this point in the history
This was sent as a patch by a Jan Tojnar. Original commit message:

> It expects much stricter datetime format, with explicit timezone offset.
>
> Let’s use `datetime.now(timezone.utc)` which unlike the naive datetime
> returned by `datetime.utcnow()` contains a timezone.

Link to patch: https://lists.sr.ht/~mjorgensen/public-inbox/patches/24051
  • Loading branch information
prplecake authored and kostasdizas committed Jul 29, 2021
1 parent 39e6510 commit 29435b4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions activitywatch/api.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import json
import socket
import requests
from datetime import datetime
from datetime import datetime, timezone

from . import utils


class ActivityWatchApi(object):
_last_heartbeat = datetime.now()
_last_heartbeat = datetime.now(timezone.utc)
freq = 10

def __init__(self):
Expand Down Expand Up @@ -81,7 +81,7 @@ def ensure_bucket(self, bucket_id):
self.create_bucket(bucket_id)

def heartbeat(self, bucket_id, event_data, pulsetime=30):
now = datetime.now()
now = datetime.now(timezone.utc)

if not self._rate_limited(now):
return
Expand Down

0 comments on commit 29435b4

Please sign in to comment.