Datetime UTC Opening hours NF-e

Asked

Viewed 1,302 times

0

How can I change the time zone of a type variable DateTime?

The idea is to make a routine where the user does not need to change the time of the computer to perform NF-e transmissions, but is dynamic without having to fail in the code the current time zone.

  • Please explain a little better what you want to do. Maybe a pseudo-code will help.

  • The NF- There is a tag where it is necessary to pass the date and time in UTC format (-03:00), remembering that we are in daylight time it changes this time zone to (-02:00), causing the note to generate errors in the fields due to this difference. In many cases some programmers prefer not to change the time of the computer/server responsible for this type of emission, but would like a more dynamic solution without relying on the user

  • 2

    That sounds like POG to me

  • @Rovannlinhalis what its solution would be, since every computer today automatically updates the time in summer time and the revenue keeps as standard the time in GMT(-03:00). Remembering that I cannot send the time with GMT(-02:00) as I get an incorrect tag return.

  • https://msdn.microsoft.com/pt-br/library/bb495915(v=vs.110). aspx

  • 1

    Is there any reference that the recipe keeps GMT-0300 always? I don’t doubt why government makes these. The correct is to use local time, that treats daylight savings time, or UTC to be agnostic.

Show 1 more comment

1 answer

2


According to the taxpayer’s guidance manual, Sefaz does adopt daylight saving time. Therefore, you should inform the zone -03:00 when you are not in daylight saving time and -02:00 when you are (considering Brasilia time).

Example of tag dhEvento on page 81:

Data e hora do evento no formato AAAA-MMDDThh:mm:ssTZD
(UTC - Universal Coordinated
Time, onde TZD pode ser -02:00 (Fernando de
Noronha), -03:00 (Brasília) ou -04:00 (Manaus), no
horário de verão serão -01:00, -02:00 e -03:00. Ex.:
2010-08-19T13:00:15-03:00.

Manual link: http://www.nfe.fazenda.gov.br/portal/exibirArquivo.aspx?conteudo=URCYvjVMIzI=

One problem that may happen, is that in windows there is the option Ajustar automaticamente para o horário de verão

inserir a descrição da imagem aqui

(Consider shipping time as now, 14:00)

If this option is not checked, and your time is correct, you will send 14:00 in the -03:00 zone and the Sefaz will receive at 14:00 in the -02:00 zone. There will be rejection.

The correct is the option to be checked, and the upload will be in zone -02:00, even if your zone is (UTC-03:00) Brasília.

I did some tests:

Windows Zone (UTC-03:00) Brasilia, unchecked option:

Console.WriteLine(DateTime.Now.ToString("yyyy-MM-ddTHH:mm:sszzz"));

Upshot: 2017-11-08T14:05:55-03:00

Windows zone (UTC-03:00) Brasilia, option checked:

Console.WriteLine(DateTime.Now.ToString("yyyy-MM-ddTHH:mm:sszzz"));

Upshot: 2017-11-08T14:03:34-02:00

Browser other questions tagged

You are not signed in. Login or sign up in order to post.