Opsive 0 Newbie Poster

Sorry I'm back again, five days ago everything looked so good but now I am confused as ever.

Take for example the story "Police Secretly Planting GPS Devices On Cars" posted recently on Slashdot. It has a date of 2008-08-13T23:15:00+00:00. I am running the following code:

utcTime= mktime(datetime(*entryDate[0:6]).timetuple())

This code returns a time of 1218683700, while according to the date 2008-08-13T23:15:00+00:00 that number should be 1218669300, or four hours behind. Where are these four hours coming from?

Any help would greatly be appreciated (I'm pulling my hair out with this epoch time stuff)

Thanks,
Justin

Opsive 0 Newbie Poster

So that says that I shouldn't manually modify time_t, but I still don't think a difference of five hours is correct.

Opsive 0 Newbie Poster

Thanks, I think we almost have it. I just ran it and got:

1218659645.000000
1218677645.000000

The difference between the two is five hours, but this is being run from a pc set to EST, so I would expect a difference of four hours. Is there something wrong with the c++ code or the way the pc is setup? Doing the date command in the terminal window brings up:
Wed Aug 13 16:37:13 EDT 2008
So it looks like it is set to the correct timezone.

Thanks,
Justin

Opsive 0 Newbie Poster

On most unix compilers, time(NULL) returns the number of seconds since January 1, 1970. If I do time(NULL) right now, it gives me 1218651371 (in EST). What I want it to give me is 1218665771, the UTC time of the local time. Does that make sense?

Thanks for your help.

Opsive 0 Newbie Poster

I'm confused. When I do:

cout << time(NULL);

That outputs the local epoch time, should it not according to your statement? gmtime outputs the time as UTC, but it is not in epoch format. Is there a way to convert it to epoch format?

Opsive 0 Newbie Poster

Hah, interesting perspective of time_t.

What I am trying to do is to get the UTC epoch time from the local time, is there an easier way to do that?

Opsive 0 Newbie Poster

How do you convert a UTC tm structure to a UTC time_t structure? mktime would work except it converts the time back to local time.

Here is what I have so far:

time_t t = time(NULL);
	tm *ptm = gmtime(&t);

Thanks,
Justin

Opsive 0 Newbie Poster

Ohh, I didn't see that, thank you! That makes things really easy.

Thanks again,
Justin

Opsive 0 Newbie Poster

I am going through a list of rss feeds and getting the date from each entry in the feed. I know that every rss feed isn't going to have the same convention for displaying the timezone so I'm hoping that the feedparser figures that out for you, but I don't know how to use that functionality (if it even exists).

But for example, entryDate[0:6] returns a tuple like (2008, 2, 27, 0, 15, 15). This doesn't contain any timezone information. entryDate follows the python time tuple convention, so you can't pull the timezone from there. I was looking at the feed parser reference page, and didn't see anything dealing with timezone but hopefully I am missing something (I would think that would be a pretty basic for such a commonly used script)

Thanks for your help,
Justin

Opsive 0 Newbie Poster

Hello,

I am writing a little script that needs to get the timezone from an rss feed, and I am using Feed Parser to parse the rss feeds. The way that I am converting the date into Unix Epoch time is:

feedDate = feed['feed'].get('updated_parsed') or feed.entries[0].get('updated_parsed')
feedDate = mktime(datetime(*feedDate[0:6]).timetuple())

This code doesn't take into account the timezone information, but I am wondering if it is possible to. Is there a way to modify my code so that it will?

Thank you,
Justin