Home | Trees | Indices | Help |
|
---|
|
1 #!/usr/bin/python 2 # 3 # Copyright (c) 2010 Red Hat, Inc. 4 # 5 # This software is licensed to you under the GNU General Public License, 6 # version 2 (GPLv2). There is NO WARRANTY for this software, express or 7 # implied, including the implied warranties of MERCHANTABILITY or FITNESS 8 # FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 9 # along with this software; if not, see 10 # http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. 11 # 12 # Red Hat trademarks are not licensed under GPLv2. No permission is 13 # granted to use or replicate Red Hat trademarks that are incorporated 14 # in this software or its documentation. 15 16 ''' 17 Utilities for parsing and formatting of JSON values. 18 ''' 19 20 from datetime import datetime 2123 ''' 24 Parses the pymongo.json_util encoding of a datetime instance. The instance is 25 encoded as a 64-bit unsigned integer for milliseconds since epoch, according to 26 JSON strict mode. This method also assumes the strict mode packaging of a dict 27 using $date as the key for this integer. 28 29 Example: 30 { "$date" : 1283505509571} 31 32 @param date_string: JSON encoded datetime instance 33 @type date_string: dict with the date integer stored at $date 34 35 @return: python object representing the date 36 @rtype: L{datetime.datetime} instance 37 ''' 38 return datetime.utcfromtimestamp(float(date_string["$date"]) / 1000.0)39
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Tue Sep 7 12:30:37 2010 | http://epydoc.sourceforge.net |