Ruby’s Time.now

December 2, 2008 § 2 Comments

I really miss Ruby’s Time.now.to_i, too bad Python does not have something as convenient.

So I created one:

import datetime
import time

class TimeUtil():
	@classmethod
	def to_i(cls, t=None):
		if t is None:
			t = datetime.datetime.utcnow()
		return time.mktime(t.timetuple())

Where Am I?

You are currently viewing the archives for December, 2008 at RAPD.