I need to determine whether day light savings enabled for a given UTC offset in Linux(Redhat).
I get input such as UTC+05:30.
I checked the usage of zdump command. When used with time zone name, we can check the value of isdst in the output to determine the status of daylight-savings.
zdump -v /usr/share/zoneinfo/Asia/Kolkata | grep 2013
As above, zdump requires zone name. It doesn’t accept UTC offset.
I also tried localtime function as below.
time_t currtime;
struct tm * timeinfo;
timeinfo = localtime ( &currtime );
time_t local = mktime( timeinfo );
cout<<timeinfo->tm_isdst<<endl;
The above code works when time zone name is set in date time settings. It doesn’t work if system is using UTC time. I used gmtime instead of localtime when UTC time is used.
Please let me know if there is any way to determine whether dst is enabled or not using UTC offset.
This is in general not possible. UTC+05:30 might be used by many countries, each with a different daylight savings time policy.