Python Epoch Seconds — WTF?

This is how you convert a Python datetime object into an epoch second:

(datetime.datetime(2012,04,01,0,0) - datetime.datetime(1970,1,1)).total_seconds()

No, seriously, that’s how.

And that’s completely unacceptable. What the hell? How can I possibly have to subtract the beginning of epoch, get a different object entirely, and then call a method on that object in order to get by far the most portable timestamp representation in the world, from Python’s one-and-only standard library timestamp object? Guys, it’s not this klutzy in Java.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s