Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 12-04-2006
Genner Genner is offline
Miembro
 
Registrado: feb 2006
Posts: 44
Poder: 0
Genner Va por buen camino
Post Zona horaria

Buen dia,
estoy haciendo una aplicacion en la cual tengo q sincronizar la hora y fecha de un servidor de internet. Hasta aqui todo bien
Código Delphi [-]
Tidsntp.Host:='cronos.cenam.mx';
Tidsntp.SyncTime;
Tidsntp.DateTime;
label1.Caption:='Fecha actual '+DateToStr(Tidsntp.DateTime)+' Hora actual '+ TimeToStr(Tidsntp.DateTime);
la cosa es q aqui en Mexico hay horario de verano y el servidor me regresa una hora menos cuando, la explicacion q dan en cronos.cenam.mx es q la configuracion de la zona horaria de la pc debe ser (GMT-06:00) hora central EE.UU y CANADA.
La pregunta es, Hay alguna forma de controlar la zona horaria desde delphi??

Muchas gracias por su tiempo
Responder Con Cita
  #2  
Antiguo 17-04-2006
Avatar de Lepe
[Lepe] Lepe is offline
Miembro Premium
 
Registrado: may 2003
Posts: 7.424
Poder: 28
Lepe Va por buen camino
Según acabo de ver es algo lioso el tema:
Cita:
Under legislation enacted in 1986, daylight saving time in the USA

begins at 2 a.m. on the first Sunday of April and
ends at 2 a.m. on the last Sunday of October

In most of the countries of western Europe, including the countries that are members of the EEC, daylight saving time:

begins at 1 a.m. GMT on the last Sunday of March and
ends at 1 a.m. GMT on the last Sunday of October

Daylight Saving Time - for the U.S. and its territories - is not observed in Hawaii, American Samoa, Guam, Puerto Rico, the Virgin Islands, the Eastern Time Zone portion of the State of Indiana, and by most of Arizona (with the exception of the Navajo Indian Reservation in Arizona).

In many other countries around the world, daylight saving time lasts from March 30th to October 26th.


This article from the link: http://www.timechange.com/dls/dls1.html
Extraido de http://www.thanhda.com/community/ind...;threadid=2547


Con el siguiente código sacas la fecha según los americanos, quizás tengas que adaptarla.
Código Delphi [-]

procedure TForm1.Button1Click(Sender: TObject);
var
  tzInfo: TTimeZoneInformation;
  StandardDate: TDate;
  DayLightDate: TDate;

begin
  GetTimeZoneInformation(tzInfo);

  DaylightDate := EncodeDate(
    yearof(date),
    tzInfo.DaylightDate.wMonth,
    tzInfo.DaylightDate.wDay
  );
  ShowMessage(FormatDateTime('dd-mm-yyyy',DayLightDate));



  StandardDate := EncodeDate(
    yearof(date),
    tzInfo.StandardDate.wMonth,
    tzInfo.StandardDate.wDay
  );
  ShowMessage(FormatDateTime('dd-mm-yyyy',StandardDate));

end;

Para hallar el primer domingo de un mes determinado uso esto:
Código Delphi [-]
          // si la fecha de aviso era un domingo,
          // averiguamos el primer domingo del mes de la Fecha
          DecodeDayOfWeekInMonth(FechaAviso, y, m, an, d);
          NotaActualizada := EncodeDayOfWeekInMonth(YearOf(Fecha),
            MonthOf(Fecha),
            1, // aqui el primero, si queremos el último domingo, poner un 4 o 5 (depende del mes)
            d); // dia de la semana, en este caso 7 porque es un domingo lo que buscamos
          RecodeTime(NotaActualizada, HourOf(FechaAviso),
            MinuteOf(FechaAviso),
            0, 0);

Saludos
__________________
Si usted entendió mi comentario, contácteme y gustosamente,
se lo volveré a explicar hasta que no lo entienda, Gracias.

Última edición por Lepe fecha: 17-04-2006 a las 15:41:57.
Responder Con Cita
Respuesta


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Consola cualquier zona yusnerqui Varios 5 08-09-2006 19:01:45


La franja horaria es GMT +2. Ahora son las 23:01:34.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi