So I'm having an issue in Apex with the Date's addDays function. It seems that adding more than a certain amount of days throws off the time by one hour. It all seems so arbitrary so I'm wondering if this is a known thing in Salesforce or not.
DateTime aDate = System.now();
System.debug(aDate);
DateTime adjustedDate =
DateTime.newInstance(aDate.date().addDays(4), aDate.time());
System.debug(adjustedDate);
Running that in an execute anonymous box outputs the following:
2019-03-05 17:44:28
2019-03-09 17:44:28
That's all good. The same date separated by four days and the same time. Just as you'd expect. But... adding five or more days causes behavior I can't wrap my head around.
DateTime aDate = System.now();
System.debug(aDate);
DateTime adjustedDate =
DateTime.newInstance(aDate.date().addDays(5), aDate.time());
System.debug(adjustedDate);
This outputs the following:
2019-03-05 17:46:08
2019-03-10 16:46:08
It falls back by an hour. Any idea why or is this a known thing? I'm in central timezone so my time is actually -6 hours from the printed time.