Source code for pypuppetdb.utils

from __future__ import unicode_literals
from __future__ import absolute_import

import warnings
import datetime


# A UTC class, see:
# http://docs.python.org/2/library/datetime.html#tzinfo-objects
[docs]class UTC(datetime.tzinfo): """UTC""" def utcoffset(self, dt): return datetime.timedelta(0) def tzname(self, dt): return str('UTC') def dst(self, dt): return datetime.timedelta(0) def __repr__(self): return str('<UTC>') def __str__(self): return str('UTC') def __unicode__(self): return 'UTC'
[docs]def json_to_datetime(date): """Tranforms a JSON datetime string into a timezone aware datetime object with a UTC tzinfo object. :param date: The datetime representation. :type date: :obj:`string` :returns: A timezone aware datetime object. :rtype: :class:`datetime.datetime` """ return datetime.datetime.strptime(date, '%Y-%m-%dT%H:%M:%S.%fZ').replace( tzinfo=UTC())
Read the Docs v: v0.1.0
Versions
latest
v0.1.0
v0.0.4
Downloads
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.