I have strange problem and would like to use one of yours opinion.
I am setting up servers grid, all will be based in UK at first and then expand to other countries. My problem is should I stick with GMT or use BST, what is your opinion in terms of global timezone settings?
I don't quite know where are you going to set 'global timezone', but if you want to know my opinion, I would always store time-related information in UTC (not in GMT, there is slight but important difference between them) and convert it to local user timezone upon displaying. That's just safer method.
BST have one inconvenient property – Daylight Saving Time. It changes so, there are dates that does not exist and dates which are here twice (I wrote few words about it on my blog). If you want to convert timezones, there could be an ambiguity. So just stick to UTC and there should be no problems with conversions.
Related
I have been searching around and saw the jira https://issues.apache.org/jira/browse/AVRO-739 for this matter, but I don't have a better sense of what avro support for date time within the user document. What I trying to achieve is to code the date with timezone information (with iso8601) from the kafka producer side in python and all the downstream consumers are written in java can decode it properly. what is the best practice for this?
The best practice is to simply encode the number of seconds/milliseconds since 1970-01-01 UTC, also known as Unix or Epoch time, and then convert to whatever timezone you want on the client side. This has been the only sane approach that worked for me over the years.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have 5000+ airport codes (with latitude, longitude) in a table and timezone list is available in a master table with these timezones: http://support.microsoft.com/kb/973627.
How can I map the timezone to an airport code? For same offset we can have multiple time zones. Example: GMT-06:00 has multiple timezone names.
The mapping list available on websites do not have the same timezone names which are there in the link.
This isn't something that SQL Server can do natively, you will have to map lat/lon to timezone yourself, see http://timezonedb.com/ for an opensource dataset that might help you.
NOTE The list of Windows Timezones for Windows XP is invalid. It has changed several times in the past, the latest only a few months ago. In any case, Windows timezone names aren't used in travel, or anywhere else for that matter.
GMT-6 isn't a timezone, it's an offset. Timezones are those found in the IANA database, eg. Russia\Moscow. Depending on time of year the offset changes. Actually, Russian time zones have changed many times over the last decade so you need to know the full date to calculate the offset.
The IANA database contains all timezones and the rules to calculate their offsets back to the 19th century.
Your airport reference table should contain the airport code and the timezone, resolving the offsets in client code. Storing the offsets isn't practical. Not only do they change, but there are no fixed dates to mark the change from winter to summer time.
I understand this is a bit of pain when you want to calculate travel durations. If the number of calculations isn't very large, you can do everything client-side. The IANA database isn't large and is often embedded in libraries, which means each calculation costs a few CPU cycles. Another option is to create a SQLCLR assembly to do the translation on the server. Even big travel agencies (as in Top 10 in Europe) don't need that though.
In Linux systems the IANA timezone database is part of the OS and you can resolve offsets with system calls. In Windows, you can use a library like NodaTime to resolve timezones to offsets.
The IANA database is updated regularly. Libraries that embed it have to be recompiled with the new data, which means you have to update whichever you use as well.
All airport reference data eg from Flightstats or other providers always contain the timezone.
If you care about airport timezones, you should avoid using datetime in SQL Server and use datetimeoffset wherever possible. Rather than assume that all travel dates are local dates (thus requiring airport lookups and conversions), be explicit. All airlines post their schedules with valid offsets anyway. This can make duration calculations a lot easier.
As for matching airports to timezones
This process can't be fully automated, because all datasets (even commercial offerings) have omissions. Even if you buy a commercial service, there will be cases where the airport is missing and you have to google for it by city name etc. This can happen for example if an airport hasn't opened yet but airlines have started selling flights from/to it.
Matching coordinates to timezones isn't very helpful. It's easier to match the airport codes themselves. There are several services that offer web service or REST endpoints which you can call to request airport information. Understandably, the free/open source services are less reliable than the commercial offerings.
As a starting point, you should find some services, query them for the airports you already have and keep the information, updating it whenever a new airport comes up. Expect to spend some time cleaning up the data though.
Consider subscribing to a commercial service - they have adopted a per-use model that costs very little if you only have 5000 calls to make. They also provide a lot of information like coordinates, locations, performance informations etc.
I have been searching the web for some simple world clock program that will run in the background without the use of internet connection. Instead I found this site using Google search: http://wwp.greenwichmeantime.com/info/global.htm
Now I would like some opinions on which language would fit best to the program I would like. Basically it will look like a simple 2 column table. Column 1 will be the time zone and column 2 as current time according its respective zones. It will just continuously run in the background while not consuming too much memory. The local time of the computer will be used as the base.
Again this will be an OFFLINE world time zone, so a desktop-application.
Features may include these as well but not necessary:
The time will be at 24 hour format to make it easier to read (well I find it easier and might be necessary).
Transparency setting.
Always on top.
I have learned some basic programming languages but don't know how to make this project in actuality since I haven't touched on the "visual" parts of the languages. I've seen some applications built on java but I haven't learnt it yet. I know basic python and basic C++.
Here's what I think it will look like: http://imgur.com/8ZdisWX
Just make it longer vertically so every time zone will fit.
First some notes. The page you link to show 24 timezones. This is for all practical use a lie. There are isn't 24 time zones, there are hundreds. 408, to be specific, of which several have more than one name, so there are 548 different names. http://en.wikipedia.org/wiki/List_of_tz_database_time_zones If you are on Windows, you might want to use Windows internal registry of time zones. It has fewer, but still hundreds of timezones.
Listing all of those is not practical. You will need a way for the user to select what time zones he wants to display. Many operating systems time/date widgets allow this already.
If you still want to do this application, then you can do this in any language whatsoever, more or less. Since you know basic Python I'd recommend you do it in Python, using pytz as the time zone library. As for GUI support, Kivy looks cool, and is very portable, even supporting iOS and Android.
Also note that time zones change often, so that you probably need to update your application a couple of times per year, just to get the latest time zone definitions. You can get around that in various more or less complicated ways. But I'd leave that for overcourse at the moment.
This is a tricky scenario so I will try to explain myself well. We have a system that will have users in different time zones but that will have a program they all participate in that will expire and no longer be visible to them at midnight on a given date.
We are storing the dates in UTC but if we have a user in say India which is I believe 5:30 hours ahead of UTC so if we leave it as UTC for everyone they will be able to see the program for an additional 5:30 hours and if we have a user in Seattle which is -8:00 hours behind the program will end at 4pm. None of this takes daylight savings into account.
My question is what is the best way to handle this, I have spent hours searching and there are various options none of them ideal.
Add an option to their profile for them to select a timezone, will need to be translated, a fair amount of work, etc. If we allow them to change it they could set to a timezone that allows them to keep seeing items after they should have expired. Or we set a timezone and they can't change it but not very intuitive if they move, travel, etc.
Use the browser to get the offet by javascript, again open to abuse, changing dates, etc.
What is the best way to handle this? how are other people doing it? any help would be greatly appreciated.
Both these approaches are acceptable. It depends on wether user's location has an essential role in your program or not. It also depends on how 'virtual' the program is.
For example, if it shows wether some store is open or not than the second approach is better. It is also easier to implement and it really isn't that unreliable.
But if the program is virtual and the midnight is just an agreement than the first approach is better. Of course, it is more difficult to implement, but in the virtual world it looks much better.
Normally, Rails stores all times in the database in UTC time. If you set your time zone to be something else, it converts automatically between that zone and UTC when you save to the database or retrieve from it.
What are some of the advantages of this approach? Are there any disadvantages? Is there any way to have Rails use a different time zone?
I think some of the advantages may be:
UTC removes the ambiguities of seasonal time changes
You can present different time zones to different users while keeping things consistent in the database
The only disadvantage I can think of is that, for an internal app where all users are actually in the same time zone, this difference makes it harder to run raw SQL queries based on local time.
This question has a little bit of a religious feel to it, but I'm going to answer it based on my personal experience.
Always store dates in an unambiguous form. Storing the date in UTC is pretty much the standard in that regard.
Advantages:
You can do simple math on date-times in the database without needing to convert them.
You can adjust the display of the dates at the presentation layer
Web applications can use a little bit of javascript to display local time
Disadvantages:
You need to convert all the times into some 'local' time on display
Localtime <-> UTC conversions incur a small processing penalty
Can you get rails to do something different? Possibly, but I've never tried as it just was too much work to fight what IMHO was a sensible design.
Does it make sense to use UTC from a 'just use my timezone' sense? Yes. Your server could be in California, your users in New York and who decides what is local time in that case. The server? The users? Mike, who just happens to be in London for the week on a business trip? In this case what timezone do you use?