Página 8 de 10
Re: Crear SolicitaDescarga de los servicios web de descarga masiva del SAT
Publicado: Mié Oct 31, 2018 8:53 pm
por jc_charlymx
Buen dia
El horario que manejan es el UTC (Tiempo Universal Coordinado)
https://www.worldtimeserver.com/hora-exacta-UTC.aspx
la mayoria de los frameworks tienen una función nativa que la devuelve.
Saludos
Re: Crear SolicitaDescarga de los servicios web de descarga masiva del SAT
Publicado: Mié Oct 31, 2018 9:45 pm
por s3cr3to
Quizá esto es lo que ocupas DADO:
Display UTC time in Delphi. De ahí y por allá hice este ejemplo:
Código: Seleccionar todo
program localtime2UTC;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils
, WinApi.Windows
, System.DateUtils
;
function CurrentLocalBias: TDateTime;
const
MinsInDay = 1440;
var
TZInfo: TTimeZoneInformation;
begin
//Get the between UTC and time for this locale and convert
//to TDateTime by dividing by MinsInDay
//NB: If local time is ahead of UTC, bias is negative
case GetTimeZoneInformation(TZInfo) of
TIME_ZONE_ID_DAYLIGHT:
Result := (TZInfo.Bias + TZInfo.DaylightBias) / MinsInDay;
TIME_ZONE_ID_STANDARD:
Result := (TZInfo.Bias + TZInfo.StandardBias) / MinsInDay;
TIME_ZONE_ID_UNKNOWN:
Result := TZInfo.Bias / MinsInDay;
else
Result := TZInfo.Bias / MinsInDay;
end;
end;
function UTCTimeNow: TDateTime;
begin
//UTC time = local time + Bias + Standard/Daylight bias
Result := Now + CurrentLocalBias;
end;
function GetTimeZone: string;
var
TimeZone: TTimeZoneInformation;
begin
GetTimeZoneInformation(TimeZone);
Result := 'GMT ' + IntToStr(TimeZone.Bias div -60);
end;
function LocalToUTC(LocalTime: TDateTime): TDateTime;
var TimeZoneInformation: TTimeZoneInformation;
Bias: integer;
begin
Bias := 0;
case GetTimeZoneInformation(TimeZoneInformation) of
TIME_ZONE_ID_STANDARD: Bias := TimeZoneInformation.Bias + TimeZoneInformation.StandardBias;
TIME_ZONE_ID_DAYLIGHT: Bias := TimeZoneInformation.Bias + TimeZoneInformation.DaylightBias;
end;
result := LocalTime + (Bias * OneMinute);
end;
var
tdt : TDateTime;
begin
try
{ TODO -oUser -cConsole Main : Insert code here }
writeln (GetTimeZone);
tdt := LocalToUTC(now);
Writeln(FormatDateTime('c',tdt));
Writeln(FormatDateTime('c',UTCTimeNow));
readln;
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
end.
Y este otro (con unos comentarios muy interesantes):
How to convert Local time to UTC time in Delphi XE2? and how to convert it back from UTC to local time?
...
A word of warning. Do not expect the attempt to account for daylight savings at the time being converted to be 100% accurate. It is simply impossible to achieve that. At least without a time machine. And that's just considering times in the future. Even times in the past are complex. Raymond Chen discusses the issue here: Why Daylight Savings Time is nonintuitive.
David Heffernan
Esa última nota es interesante:
Why Daylight Savings Time is nonintuitive
... One reason is that it means that FileTimeToLocalFileTime and LocalFileTimeToFileTime would no longer be inverses of each other. If you had a local time during the "limbo hour" during the cutover from standard time to daylight time, it would have no corresponding UTC time because there was no such thing as 2:30am local time. (The clock jumped from 2am to 3am.) Similarly, a local time of 2:30am during the cutover from daylight time back to standard time would have two corresponding UTC times.
Another reason is that the laws regarding daylight savings time are in constant flux. For example, if the year in the example above was 1977 instead of 2000, the conversion would have been correct because the United States was running on year-round Daylight Savings Time due to the energy crisis. Of course, this information isn't encoded anywhere in the TIME_ZONE_INFORMATION structure. Similarly, during World War 2, the United States went on DST all year round. And between 1945 and 1966, the DST rules varied from region to region.
DST rules are in flux even today. The DST cutover dates in Israel are decided on a year-by-year basis by the Knesset. As a result, there is no deterministic formula for the day, and therefore no way to know it ahead of time. ...
Desprecio con las tripas el cambio de horario!
Re: Crear SolicitaDescarga de los servicios web de descarga masiva del SAT
Publicado: Mié Oct 31, 2018 11:08 pm
por Dado
gracias s3cr3to, estudiandole encontre una forma mas simple de obtener la hora UTC de "Hoy/ahorita"
Código: Seleccionar todo
function NowUTC : TDateTime;
var SystemTime: TSystemTime;
begin
GetSystemTime(SystemTime);
Result := SystemTimeToDateTime(SystemTime);
end;
Hice pruebas cambiando la fecha y la hora de mi compu, para adelante, para atras y resulto positivo en todos los casos
Mañana (mmmm, hoy?) hago pruebas ya con el web service de la descarga masiva, pa'ver que panchos hace.
Re: Crear SolicitaDescarga de los servicios web de descarga masiva del SAT
Publicado: Vie Nov 02, 2018 5:39 pm
por shakira
Buenas tardes. ¿acruz podrías facilitarme un correo para enviarte un mensaje, por favor?
Gracias.
Re: Crear SolicitaDescarga de los servicios web de descarga masiva del SAT
Publicado: Vie Nov 02, 2018 5:42 pm
por Dado
En el recuadro a la derecha del mensaje, justo abajo de su nick esta la leyenda "Contactar :" y un icono de mensaje, haz clic ahi para ver su direccion de email
Re: Crear SolicitaDescarga de los servicios web de descarga masiva del SAT
Publicado: Vie Nov 02, 2018 8:14 pm
por shakira
Muchas gracias, DADO. ¿No tienes vida social? JAJAJAJA, ntc...
Que tengas un excelente fin de semana.
PD No me sale ese pequeño ícono de llamada.
Re: Crear SolicitaDescarga de los servicios web de descarga masiva del SAT
Publicado: Vie Nov 09, 2018 12:03 pm
por GoLoco
hola ,
Ya logre autenticarme y sacar el token, tengo y he estado analizando el codigo de halcon divino, sin embargo, estoy haciendo el request manual en Go y al momento de crear la solicitud de descarga masiva, no logro decifrar como se calcula el "DigestValue".
Nota: Si cambio fecha inicial y fecha final con programa de halcondivino sigue generando el mismo hash,eso quiere decir que no es el nodo solicitud.
Alguien tiene este dato?
Código: Seleccionar todo
<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SolicitaDescarga xmlns="http://DescargaMasivaTerceros.sat.gob.mx">
<solicitud RfcEmisor="CHHH000421XXX" RfcSolicitante="CHHH000421XXX" FechaInicial="2018-03-01T00:00:00" FechaFinal="2018-03-07T00:00:00" TipoSolicitud="CFDI">
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
<SignedInfo>
<CanonicalizationMethod Algorithm="Algorithm" />
<SignatureMethod Algorithm="Algorithm" />
<Reference>
<DigestMethod Algorithm="Algorithm" />
<DigestValue>onjoYp8Pcr1t0r73J3LRNGlGjIU=</DigestValue>
</Reference>
</SignedInfo>
<SignatureValue>MII...IDAQAB</SignatureValue>
<KeyInfo>
<X509Data>
<X509IssuerSerial>
<X509IssuerName>OID.1.2.840.113549.1.9.2=Responsable: Administración Central de Servicios Tributarios al Contribuyente, OID.2.5.4.45=SAT970701NN3, L=Cuauhtémoc, S=Distrito Federal, C=MX, PostalCode=06300, STREET="Av. Hidalgo 77, Col. Guerrero", E=acods@sat.gob.mx, OU=Administración de Seguridad de la Información, O=Servicio de Administración Tributaria, CN=A.C. del Servicio de Administración Tributaria</X509IssuerName>
<X509SerialNumber>00003030310000003030343030383233000000</X509SerialNumber>
</X509IssuerSerial>
<X509Certificate>MIIGoz...eydk=</X509Certificate>
</X509Data>
</KeyInfo>
</Signature>
</solicitud>
</SolicitaDescarga>
</s:Body>
</s:Envelope>
Re: Crear SolicitaDescarga de los servicios web de descarga masiva del SAT
Publicado: Vie Nov 09, 2018 3:36 pm
por crono81
Dale una leida al hilo completo, ahi estan las respuestas.
Debes firmar este nodo
Código: Seleccionar todo
<des:solicitud FechaFinal="2017-01-02T15:00:00" FechaInicial="2017-01-02T00:00:02" RfcEmisor="XXXXX" RfcSolicitante="XXXXX" TipoSolicitud="CFDI"></des:solicitud>';
Respetando el orden de los atributos, además ten en cuenta que yo uso el namespace "des"
Re: Crear SolicitaDescarga de los servicios web de descarga masiva del SAT
Publicado: Vie Nov 09, 2018 4:27 pm
por GoLoco
hola cronos, ya lei el hilo completo tambien lei esa parte que sacando el hash de ese nodo "solicitud", pero te comento que al bajar el codigo de halcondivino, que efectua las peticiones bien, genera un mismo hash siempre aunque cambies la fechainicial y fechafinal, es decir no puede venir del nodo que dices porque que al cambiar las fechas cambia el string por consecuencia , cambia el hash.
no se si me explique bien.
Tu ya lograste hacer la peticion de descarga?
Re: Crear SolicitaDescarga de los servicios web de descarga masiva del SAT
Publicado: Vie Nov 09, 2018 4:35 pm
por Dado
Que trabajo nos costo llegar a esa conclusion, para que te digan "NO" y ni siquiera lo intenten
