With this in mind:
https://docs.python.org/2/library/datetime.html#timedelta-objects (hint: 0
<= microseconds < 1000000)

return ((time_delta.days * 86400 + time_delta.seconds)*10**6 +
         time_delta.microseconds) / 10**6

becomes equivalent with

return time_delta.days * 86400 + time_delta.seconds

This is to say that 2.999999 seconds are considered to be 2 seconds for our
purpose. Claiming that the token expires in 3 seconds (the way originally I
intended) might upset some purists. Better to under promise and over
deliver than the other way around.

Are we on the same page?


On Tue, Jun 3, 2014 at 9:57 AM, Craig Citro <notifications@github.com>
wrote:

> In oauth2client/client.py:
>
> > @@ -625,6 +628,16 @@ def set_store(self, store):
> >      """
> >      self.store = store
> >
> > +  def _expires_in(self):
> > +    """Get in how many seconds does the token expire."""
> > +    if self.token_expiry:
> > +      now = datetime.datetime.utcnow()
> > +      if self.token_expiry > now:
> > +        time_delta = self.token_expiry - now
> > +        return int(round(time_delta.days * 86400.0 +
>
> ugh, 2.6. ;)
>
> ok, so let's shorten it slightly -- in particular, i'd like to just copy
> the existing code from the stdlib (maybe even leaving a note saying "TODO:
> switch to total_seconds when we drop 2.6 compatibility"):
>
> return ((time_delta.days * 86400 + time_delta.seconds)*10**6 +
>          time_delta.microseconds) / 10**6
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/google/oauth2client/pull/15/files#r13345606>.
>



-- 
Orest Bolohan

Software Engineer
Cloud/TI Identity and Access Management Services
Google Inc.
Mountain View, CA

(650) 214 3458
orest@google.com