In Chile the case is very particular as the days of daylight saving changes are different a year from another...
Is there a function to get for given day at given UTC time the UTC offset?
I saw on a Suse documentation that something like zdump -v /usr/share/zoneinfo/Chile/Continental
makes me enable to get all changings through years, but the job has to be done still... any command to do that?
Or/and is there a function with a given date and time from given timezone to UTC? And its reverse?
How does linux handle these changes? didn't find more documentation than Suse one.
You can use the
date
command. You set the timezone and then specify the date and time. The command will return that time with the -03 or -04, so you will know if DST was in effect.For example, for Chile/Continental:
Before DST change this year:
After DST change this year:
To undo that, just set TZ to UTC and change the offset:
Based on Eduardo Trápani's answer, the final answer for me was
TZ=Chile/Continental date --date='TZ=Chile/Continental date --date='2020-04-05 02:00:15 +00' +%z
which gives-0300
TZ=Chile/Continental date --date='2020-04-05 04:00:15 +00' +%z
which gives-0400
List zones
ls -l /usr/share/zoneinfo/
See details of a particular zone
zdump -v /usr/share/zoneinfo/Chile/Continental