Respondido TimeZone

  • quinta-feira, 10 de maio de 2007 23:10
     
     

    Olá pessoal,

     

     Para tornar mais fácil o entendimento vou descrever o quero fazer:

     

    1) A pessoa coloca login, senha e diz qual o fuso horário que ele está. Aqui, no meu PC, o meu é E. South America Standard Time.

     

    Preciso de uma combobox populada com os fuso horários que existem, ou um picker, o que seja, mais que mostra os fuso horários disponíveis (Nesse formato retornado pela função System.TimeZone.get_CurrentTimeZone();

     

    Obrigado.

Todas as Respostas

  • sexta-feira, 1 de junho de 2007 03:41
     
     Respondido

    Não há nenhum mecanismo no .NET Framework para listar os fusos horários existentes. A explicação é:

     

    "People are often surprised why this feature cannot be supplied by Microsoft at low cost. In particular, data to do conversions exists in the Windows registry and is used by the time zone selection dialog. However, there is a big distinction between having UI and registry data and having an API.

    This is a more expensive feature to undertake for Microsoft than most people would imagine because (a) an API must provide consistent behavior from one machine to another so we cant just re-expose the registry data and (b) there is cost for Microsoft in exposing an official Time Zone conversion because we face on-going geo-political costs for any country/region based data we gather and maintain. For example, a country may threaten to boycott our product if they are not listed in the data. This has happened to us with our CultureInfo data on many occasions, and we often need to tweak data in service packs, which is expensive and risky."

    De qualquer forma, a informação que você procura está no Registry. Use a classe Registry para enumerar o conteúdo de HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones. Veja um exemplo (em VB.NET) em http://vbnet.mvps.org/index.html?code/locale/timezonedisplay.htm