Andy_Needham
asked on
Convert given date (from known timezone) to GMT/UTC.
I have a server running in GMT/UTC (no daylight saving). All data is to be stored with GMT date/timestamps. I now have a problem because some data is being posted with a date/timestamp in CET (CET is either GMT+1 or GMT+2 depending on DLS).
So I need to find a way to convert the date/timestamp to GMT. The big problem is to determine what the relevant offset is. It is important that the calculated offset was relevant at the date/timestamp time, rather than at time 'now'.
One minor issue: for one hour each year (in the autumn/fall) , there may be date/timestamps which are indeterminant - it is not possible to know if they relate to just before or just after the clock change. For my application this does not matter (phew!).
The solution could be implemented in a number of ways and languages, but a 'System DLL' call or a VB6 module would be favourite. Alternatively an algorithm would be fine.
Thanks.
So I need to find a way to convert the date/timestamp to GMT. The big problem is to determine what the relevant offset is. It is important that the calculated offset was relevant at the date/timestamp time, rather than at time 'now'.
One minor issue: for one hour each year (in the autumn/fall) , there may be date/timestamps which are indeterminant - it is not possible to know if they relate to just before or just after the clock change. For my application this does not matter (phew!).
The solution could be implemented in a number of ways and languages, but a 'System DLL' call or a VB6 module would be favourite. Alternatively an algorithm would be fine.
Thanks.
See Java DateFormat object and setCalendar and setTimeZone methods.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks earthman2 - but I tried to access the FTP site you mentioned, but could not logon. To be honest though, I do not have Java development tools or experience.
What are the rules for DST in your timezone ?
Usually you just need function to determine say the last but one sunday in the month.
Usually you just need function to determine say the last but one sunday in the month.
ps the timezone library is in C
ASKER
In the UK (and possible Europe in general?) the rule is that the clocks change at 02:00 on the last Sunday in March and October.
I am hoping that there is a library file that covers all time change rules for all regions. Failing that, then it will have to be a specific one for CET.
I am still trying to get hold of timezone library.
I am hoping that there is a library file that covers all time change rules for all regions. Failing that, then it will have to be a specific one for CET.
I am still trying to get hold of timezone library.
Well PostgreSQL uses this library to implement its timezone shifting.
The last post given was "I am trying to get hold of timezone library"
If "he" can't ftp get a file, or ask for more help what can we do.
The last post given was "I am trying to get hold of timezone library"
If "he" can't ftp get a file, or ask for more help what can we do.
ASKER
Tried to access the ftp site but it keeps rejecting me - bit like the wife :)
If you have any suggestions on how I might gain access to the ftp site (or the wife!) I would be mosty grateful.
Thanks
If you have any suggestions on how I might gain access to the ftp site (or the wife!) I would be mosty grateful.
Thanks
Using Fedora linux and Firefox I opened
ftp://elsie.nci.nih.gov/%2f/pub
and clicked on tzcode2005m.tar.gz and saved it to disk.
If you want me to email it to you then e-mail me your e-mail address.
ftp://elsie.nci.nih.gov/%2f/pub
and clicked on tzcode2005m.tar.gz and saved it to disk.
If you want me to email it to you then e-mail me your e-mail address.
A wife generally requires fine wine and chocolates. ;-}
ASKER
Tried to access the FTP site using FTPPro and 'DOS' - still no joy. I will therefore email you my address if you could kindly email the library to me?
Many Thanks
Andy.
Many Thanks
Andy.
ASKER
Thanks for the library - at first glance it appears to be pretty much what I was looking for!
All I need now is the wine and choc's .
Cheers.
Andy
All I need now is the wine and choc's .
Cheers.
Andy
use Class::Date;
print scalar gmtime((new Class::Date [2005,7,12,17,50,0],'CET')