~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/services/utils.py

  • Committer: Jonathan Lange
  • Date: 2011-06-30 11:17:53 UTC
  • mto: This revision was merged to the branch mainline in revision 13368.
  • Revision ID: jml@canonical.com-20110630111753-lsu4e8e3vp6a7fh5
Add utc_now

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
    'synchronize',
23
23
    'text_delta',
24
24
    'traceback_info',
 
25
    'utc_now',
25
26
    'value_string',
26
27
    ]
27
28
 
 
29
from datetime import datetime
28
30
from itertools import tee
29
31
import os
30
32
from StringIO import StringIO
38
40
    MonkeyPatch,
39
41
    )
40
42
from lazr.enum import BaseItem
 
43
import pytz
41
44
from twisted.python.util import mergeFunctionMetadata
42
45
from zope.security.proxy import isinstance as zope_isinstance
43
46
 
285
288
    variables, and helps to avoid typos.
286
289
    """
287
290
    sys._getframe(1).f_locals["__traceback_info__"] = info
 
291
 
 
292
 
 
293
def utc_now():
 
294
    """Return a timezone-aware timestamp for the current time."""
 
295
    return datetime.now().replace(tzinfo=pytz.UTC)