I´m having trouble when working with dates in my Web MVC project. It is running in my local IIS. The problem is, I live in Brazil, Rio de Janeiro, so according to a this my TimeZone is
E. South America Standard Time
That means Brasilia with GMT-3. And it is perfect and correct.
But when running my unit test in NCrunch, for the code above:
System.Globalization.CultureInfo.CurrentCulture.ClearCachedData();
var zone = TimeZone.CurrentTimeZone;
var time = zone.GetDaylightChanges(DateTime.Today.Year);
var start = time.Start;
var end = time.End;
var offset = zone.GetUtcOffset(DateTime.Now);
I ´m receiving the following results:
zone.DaylightName = "E. South America Daylight Time" (CORRECT)
time.Start = {18/10/2014 23:59:59} (CORRECT FOR 2014)
time.End = {15/02/2014 23:59:59} (CORRECT FOR 2014)
offset = {-2:00:00} (WRONT, it is -3) -> it would be right if there was no daylight saving time
TimeZone.IsDaylightSavingTime(DateTime.Now) = true
The problem is that when I send it to Postgres DB it saves as timestampZ so, it saves correct
for example 01/01/01 01:01:01 -3
But then when retrieving from database, it comes the mistake, because of the wrong offset I get
01/01/01 02:01:01 -3
It is runnin in local IIS but it should use the local computer time, right? If I go to my computer settings is is correct (Brasilia Time, GMT-3)
How should I proceed?
Thanks in regards,
Edit
Actually the problem is in my PostgresSQL. It is saving the current time with offset -3 instead of -2 and that is all the problem. When i get it back in server it adds one hour...
How do I enable DST in Postgres?!?