File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 1515# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717#
18- # $Id: date.py,v 1.91 2007-03-09 14:54:39 schlatterbeck Exp $
18+ # $Id: date.py,v 1.92 2007-03-14 15:07:24 schlatterbeck Exp $
1919
2020"""Date, time and time interval handling.
2121"""
@@ -548,6 +548,17 @@ def setTranslator(self, translator):
548548 self ._ = translator .gettext
549549 self .ngettext = translator .ngettext
550550
551+ def fromtimestamp (cls , ts ):
552+ """Create a date object from a timestamp.
553+
554+ The timestamp may be outside the gmtime year-range of
555+ 1902-2038.
556+ """
557+ usec = int ((ts - int (ts )) * 1000000. )
558+ delta = datetime .timedelta (seconds = int (ts ), microseconds = usec )
559+ return cls (datetime .datetime (1970 , 1 , 1 ) + delta )
560+ fromtimestamp = classmethod (fromtimestamp )
561+
551562class Interval :
552563 '''
553564 Date intervals are specified using the suffixes "y", "m", and "d". The
You can’t perform that action at this time.
0 commit comments