This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eric.snow
Recipients belopolsky, eric.snow, jackdied, jess.austin, mark.dickinson, ncoghlan, ysj.ray
Date 2013-08-12.23:06:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
I'm doing some string-based serialization of datetimes and need to be able to specify the type somewhat declaratively.  So I'm using a datetime subclass.  This is more or less the code I'm using:

class Timestamp(datetime.datetime):

    def __new__(cls, raw_value, *args, **kwargs):
        if not args and not kwargs:
            return cls.fromtimestamp(int(raw_value))
            return super(Timestamp, cls).__new__(cls, raw_value,
                                                 *args, **kwargs)

    def __str__(self):
        return str(int(time.mktime(self.timetuple())))

Incidently, the whole equality testing thing didn't actually cause a problem.  It was comparing against the result of `datetime.utcnow()` which has microseconds (and my Timestamp instance didn't).  Clearing out the microseconds resolved the failure so I wasn't actually bitten by this issue after all.
Date User Action Args
2013-08-12 23:06:05eric.snowsetrecipients: + eric.snow, mark.dickinson, ncoghlan, belopolsky, jackdied, jess.austin, ysj.ray
2013-08-12 23:06:05eric.snowsetmessageid: <>
2013-08-12 23:06:05eric.snowlinkissue5516 messages
2013-08-12 23:06:05eric.snowcreate