I am having the hardest time trying to get the current time in EDT timezone.
print datetime.time(datetime.now()).strftime(\"%H%M%S\")
datetime.
The tzinfo class only defines an interface, you will need to implement it yourself (see the documentation for an example) or use a third-party module which implements it, like pytz.
Edit: Sorry, I missed that you don't want to import another library.
I am not very conversent about the EDT time zone but this example should serve your purpose.
import datetime
datetime.datetime.now must be passed the time zone info which should be of type datetime.tzinfo. Here is a class that implements that with some of the required functions. I am providing no day light saving details here as this is an example.
class EST(datetime.tzinfo):
def utcoffset(self, dt):
return datetime.timedelta(hours=-5)
def dst(self, dt):
return datetime.timedelta(0)
Now you could use this to get the info with time zone correctness:
print datetime.datetime.now(EST())
Output:
2010-11-01 13:44:20.231259-05:00