How can I get timezone of a specific country? - windows-phone-7

How can I get the timezone of a specific city/country, I have the latitude and the longitude of the country. Can I do that with the TimeZoneInfo class?

No, you can't do it with TimeZoneInfo as far as I'm aware.
The Geonames web service will give you the time zone, but it will give you the zoneinfo name rather than the Windows ID. You could use the CLDR information to provide a mapping between the two of them - that's what we do for Noda Time. (You'd embed the mapping information into your app; it's reasonably straightforward.) It looks like you can also download the Geonames data, but I expect you'd have a fair amount of work to do to use it on the device.
Of course if you'd be interested in using Noda Time directly, I'd be happy to hear about your requirements. It's not quite hit production yet, but the more use cases we have, the quicker we'll be able to design the API appropriately :)

Related

How to set correct timezone for Google Classroom coursework

When creating a new Coursework via the Classroom API, a "due" date and time can be added (
Classroom API TimeOfDay reference ) and the instructions say that "The date and time zone are either not significant or are specified elsewhere.".
In the context of a class, my expectation was that the number sent would be the number displayed (the teacher generally knows what "11AM" will mean to the class).
However, what actually happens is that the time zone that the server communicating with the API is located in is used to interpret the time. I.e. if the teacher is two time zones away from the backend server, the time will be two hours out.
Is the documentation just wrong? Or is there some way to "specify elsewhere" which I can't find?
This question is a little old, but I just went through some of the same issues, so responding here in case anyone else needs help...
It's not entirely clear how you formatted your create request based on the original question. The TimeOfDay object is used to set dueTime, and as stated in the docs, all dates and times for CourseWork create requests should be converted into UTC: https://developers.google.com/classroom/reference/rest/v1/courses.courseWork
I.e. you need to do any conversions into UTC based on your application/user needs, and the Google Classroom UI automatically converts this date/time into the user's local/date time. Currently there is no other way to do this with this API
Implementing this properly can get tricky depending on how your app/UI is set up, and is further complicated by variations like Daylight Savings Time. For example, if you are using JavaScript, JS dates use UTC internally, the user's browser tracks the current time for that user, and there is currently no other built in functionality for any other timezones. See some of the really excellent explanations about this (and various workarounds) below:
Calculate the UTC offset given a TimeZone string in JavaScript
get timezone offset of another timezone in javascript without using Strings
How to initialize a JavaScript Date to a particular time zone
I hope that's at least a little helpful. It's hard to specifically answer your question about 'what's happening' without more information :)

Best/fastest way to find current user location on Windows Phone App

I am trying to figure out what is the fastest way the figure out the current user Country. I know there are a lot of location examples online, my actual is question: since I don't care much about precision, is it OK if I use RegionInfo.CurrentRegion.DisplayName; to figure out the user country?
What are the downsides of using this approach (besides precision)?
No, you shouldn't use RegionInfo.CurrentRegion for that.
For example, I live in Montenegro, but RegionInfo.CurrentRegion on my phone will return USA, which is completely irrelevant being almost 4000 miles away from here.
You have to use Geolocator class for that. Here's some sample code.

Return Specifc formatted data or more generic?

I am playing around with the ASP.NET Web API and want to use it to feed data to my mobile apps (Android, iPhone, Windows Phone).
I am wondering though should I be returning data in more of a general way or more in a specific way.
I keep finding myself trying to send more specific data back but this might because I sort of an idea of how it would look on my mobile devices but not sure if this is a good way especially if I would ever open up my API to the public.
Example
I want to tell the user how many days ago the record was inserted into the database.
Is it better to calculate on the server that it was "5" and send them back and let them append "5 days ago" or is it better just to send a datetime back and let the device parse it (this would let them do anything to the date).
In your specific example, it's better to return the DateTime occurrence rather than an interpreted named delta.
Reasons:
Time zones
Globalisation
You would like to store this event as a UTC based timestamp in the database and let the clients calculate the difference, so they can show the accurate phrasing.
Unless you store all of your globalised strings centrally in the database, it makes more sense to have that on the client side as well.

Date/Time and Internationalization for Enterprise Application -- Development Guidelines

Together with another developer, I have embarked on a journey to create a hosted 'CRM Style' application that will cater to enterprise level businesses. These businesses will be accessing our application remotely and so the hosted nature of the application will require certain features. For example, to guarantee a level of professional service the following things must be true:
internationalization requires multiple languages and presentation of date/time for various timezones and locales
transactional capability for batch processing of tasks and rollback capabilities
security concerns for keeping data safe and remote invocations secure from attack
etcetera, the list goes on and on
Due to these concerns and my role as the developer most responsible for the server side development, I am very interested in the choices I make early on. Regarding timezones and languages for example, are there issues related to my choice of database or data fields? Do I choose to use a UTC timestamp or date field throughout the application and if so is there a standard format for that? Also, regarding different languages, am I supposed to ensure the data is stored in the database as UTF-8 or unicode?
I really want to avoid laying down the infustructure of the system only to discover later that a fundamental decision was incorrect or not big enough, wide enough, smart enough, etc. Can someone point me in the right direction regarding these basic 'early' decisions?
EDIT _ Ok I appreciate the broad responses and now I see my question was a little too non-specific. I'd like to focus on the more specific elements that WERE present in the question, such as how to choose the proper format for storing a UTC Date/Time or how to save my text data (do I specify a UTF format?)
If you are targeting enterprise CRM, then you will need a very high level of customizability and integrations with all kinds of systems. You will make mistakes in the design. Your only hope is to isolate each little piece of the code so that you can have a chance of fixing it later.
In short, basic software engineering principles are your best bet.
What you are discussing is called a multi-tenant application wherein you have the same code base used by multiple customers (tenants) with logical or physical separation of data. Remember the fundamental rule of development: flexibility is relational to complexity. The more flexible you make the system, the more complicated it will be.
RE: UTC
For a CRM application that stores things like when calls were made and when meetings took place, I would definitely store all those in UTC and let the user set their local timezone. However, you might run into dates which are timezone agnostic and for those, I would store whatever date was entered.
RE: Unicode
Yes, I would use Unicode for all user-entered data. However, that will not get you localization. If for a single company for example, you have a user in Hong Kong entering text in Chinese and user in Amsterdam entering text in Dutch, you are not going to get automatic translation. Things like dates and number formats can be localized, but raw text like names used in drop lists and such can be a chore to localize.
As you have not mentioned what you think about the issue, you may find my answer or parts of it rather basic.
If you don't need to, don't use a low-level language. I'd use python usually for the first version of a CRM application (with the hope that it would be good enough for the next versions), but this decision depends also on the domain community.
Try to write the minimal code on your own, instead relying on the third-party libraries. People may disagree on this, but I would write the code myself as the last option. But the next point is important.
When selecting a library/framework to use, make sure the party behind it is going to last, the library is stable and the software license suits you needs.
Other general rules apply: focus on the customer, use continuous integration/testing, etc., use good software practices like logging etc.
Nothing is ever stored as "unicode" because this is an abstract concept. Unicode is always stored in some kind of unicode transformation format (UTF) (well or UCS but I never saw that used somewhere). The most commonly used UTF is UTF-8 but I suggest to use what is native/default to your platform. wikipedia

Finding Websites From Company Name

I've got a list of 6,000 company names (along with their headquarters address) and I need to find the web address for each of them. I'm considering using the Google Web API (obviously this will take a few days as only 1,000 queries per day are allowed) to do this(search for "COMPANY_NAME CITY STATE") and then take the first result. However I'm not 100% sure this will work, and I feel like there's a better way. I can do this in any language I know really, C++, Java, PHP, Python. This only has to be run once.
How would I use WHOIS to do this? I know how I would do it if I already knew the URL, but not the other way around(name to URL). And what would I do if it were privately registered?
BTW, these are US businesses.
You can use WHOIS instead of Google API for it.
Use Amazons Mechanical Turk. It's perfect for these kinds of tasks which can be hard to automate and typically need a person to validate them. It will cost a little but it should be manageable, depending on how bad you want the results.

Resources