![]() |
dealing with timestamped data collected in one zone and reportedin another
I'm surprised I can't find what I'm trying to do in existing modules or
maybe I'm just not looking in the right places. 8-) I'm creating some time based logs (recording the UTC as reported by gettimeofday()) in one timezone and I want to play them back in another, showing the times on the system where they were initially recorded. In other words, if I record a file in stockholm which is GMT +2 and play it back in Boston which is GMT -4, data recorded at midnight in stockholm shows up 6 hours earlier because of the time difference. The simple solution, and this is too simple as I'll get to in a minute, is to just record the timezone where the data was recorded. That way when I go to play it back I can tell there is a 6 hour difference and simply adjust the times accordingly before calling localtime() to convert them. This works like a champ, but... Although many countries around the world support daylight savings time, they do not do it on the same date! In other words, if I use my simple algorithm above it will break when one country has adjusted its clocks and the other hasn't. The one simple solution I can think of that will make this all work is that if I were do know my offset from GMT not for the current date, but for the date of the data I wish to process. But I can't seem to find any such function. Can someone help? Does someone have a better way to solve this problem? -mark |
Re: dealing with timestamped data collected in one zone and reportedin another
Mark Seger wrote:
[...] > Although many countries around the world support daylight savings time, > they do not do it on the same date! In other words, if I use my simple > algorithm above it will break when one country has adjusted its clocks > and the other hasn't. The one simple solution I can think of that will > make this all work is that if I were do know my offset from GMT not for > the current date, but for the date of the data I wish to process. But I > can't seem to find any such function. > > Can someone help? Does someone have a better way to solve this problem? > > -mark For dealing with timezones, try the modules available under DateTime. See CPAN or http://datetime.perl.org/ for more information. |
Re: dealing with timestamped data collected in one zone and reportedin another
Mark Seger wrote:
> > Although many countries around the world support daylight savings time, > they do not do it on the same date! In other words, if I use my simple > algorithm above it will break when one country has adjusted its clocks > and the other hasn't. This is OS dependent. Most Unix systems (using Olson's time code) would handle this correctly. > Can someone help? Does someone have a better way to solve this problem? Which OS are you using? Which OS is the final user going to be using? -- Just because I've written it doesn't mean that either you or I have to believe it. |
| All times are GMT. The time now is 05:15 PM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.