We have a custom Datetime
field on a custom object, Appointment__r.Start_Date__c
.
At 6pm, the day before the appointment, we must send every customer with an appointment an SMS which reminds them of the appointment, including the correct time.
We are using a batch process and scheduler to collect the relevant appointments and Twilio for Salesforce to send the messages.
Currently I am using appointment.Start_Date__c.addHours(GERMAN_TIME_OFFSET).format('HH:mm')
, where GERMAN_TIME_OFFSET = 2.
... but unfortunately summer will end, so having a hardcoded 2 will lead to incorrect results.
While I could compare Datetime.now.addDays(1) against some specific date to check whether tomorrow will be in daylights savings, every year that date will change since it the clock always changes on the last Sundays of whatever month... This doesn't seem so trivial to calculate, and (to be honest) I'm hoping there is an easier/better way.
Any suggestions/solutions?