Linux timezone automatically applies DST even when application does not send DST flag

Linux timezone automatically applies DST even when application does not send DST flag
I am working on an embedded Linux system where the application dynamically sets the system timezone based on a user-selected UTC offset. We use a predefined mapping between an internal enum and Linux timezone names, then apply the timezone by creating a symlink to /etc/localtime: static std::map> GmtValue = { { GMT_11, { "Etc/GMT+11", "GMT -11 Midway Islands, Samoa, Niue"}}, { GMT_10, { "Etc/GMT+10", "GMT -10 Fakaofo, Hawaii, Tahiti"}}, { GMT_9, { "US/Alaska", "GMT -9 Alaska, Gambier"}}, { GMT_8, { "PST8PDT", "GMT -8 Pacific Time"}}, { GMT_7, { "Etc/GMT+7", "GMT -7 Mountain Time"}}, { GMT_6, { "CST6CDT", "GMT -6 Central Time"}}, { GMT_5, { "EST5EDT", "GMT -5 Eastern Time"}}, { GMT_4, { "Etc/GMT+4", "GMT -4 Atlantic Time"}}, { GMT_3, { "Etc/GMT+3", "GMT -3 Rio de Janeiro, Buenos Aires"}}, { GMT_2, { "Etc/GMT+2", "GMT -2 Mid-Atlantic"}}, { GMT_1, { "Etc/GMT+1", "GMT -1 Azores, Cape Verde"}}, { GMT0, { "GB", "GMT 0 London, Lisbon, Dublin"}}, { GMT1, { "CET", "GMT +1 Paris, Zurich, Rome"}}, { GMT2, { "EET", "GMT +2 Athens, Sofia, Cairo"}}, { GMT3, { "Etc/GMT-3", "GMT +3 Moscow, Kuwait"}}, { GMT33, { "Asia/Tehran", "GMT +3.30 Tehran"}}, { GMT4, { "Etc/GMT-4", "GMT +4 Abu Dhabi"}}, { GMT43, { "Asia/Kabul", "GMT +4.30 Kabul"}}, { GMT5, { "Etc/GMT-5", "GMT +5 Islamabad"}}, { GMT53, { "Asia/Colombo", "GMT +5.30 Colombo"}}, { GMT6, { "Etc/GMT-6", "GMT +6 Dhaka"}}, { GMT7, { "Etc/GMT-7", "GMT +7 Bangkok"}}, { GMT8, { "Etc/GMT-8", "GMT +8 Beijing"}}, { GMT9, { "Etc/GMT-9", "GMT +9 Tokyo"}}, { GMT93, { "Australia/Darwin", "GMT +9.30 Darwin"}}, { GMT10, { "Etc/GMT-10", "GMT +10 Sydney"}}, { GMT11, { "Etc/GMT-11", "GMT +11 New Caledonia"}}, { GMT12, { "Etc/GMT-12", "GMT +12 Auckland"}}, { GMT13, { "Etc/GMT-13", "GMT +13 Nuku'alofa"}}, { GMT14, { "Pacific/Apia", "GMT +14 Apia"}} }; Function used to update the timezone: void DeviceManagement::updateSystemZoneInfo(int zone) { printf("updateSystemZoneInfo!\n"); if (zone >= ApplicationDateTimeSt::DATETIME_NUM) return; const map tzPaths = { { "/etc/localtime", "/usr/share/zoneinfo/" }, { "/etc/TZ", "/usr/share/zoneinfo/uclibc/" } }; pair tzPath; struct stat buf; for (auto &path : tzPaths) { if (!lstat(path.first.c_str(), &buf)) { tzPath = path; break; } } if (tzPath.first.empty()) return; unlink("/etc/comelit/localtime"); string newZonePath = tzPath.second + ApplicationDateTimeSt::GmtValue[zone].first; symlink(newZonePath.data(), "/etc/comelit/localtime"); } The issue is that some timezone names such as CET, PST8PDT, EST5EDT, and EET automatically apply Daylight Saving Time (DST), causing the system clock to shift by +1 hour during summer. However, the application itself does not send or manage any DST flag. The system still applies DST rules from the Linux timezone database (tzdata), which causes incorrect time behavior for our embedded product. We cannot directly modify the mapping because it is shared across multiple software components. What is the correct way to enforce fixed UTC offsets without DST adjustments on embedded Linux systems while keeping the existing timezone mapping unchanged?

Take Your Experience to the Next Level

New

Download our mobile app for a faster and better experience.

Comments

0
U

Join the discussion

Sign in to leave a comment

0:000:00