Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

system-timezone: keep looking for timezone name if it's not in Region/City format #400

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

timp87
Copy link

@timp87 timp87 commented Oct 10, 2024

plugins/datetime/system-timezone.c finds timezone name out based on system timezone config - /etc/localtime file.
Upstream python code in cinnamon-setting calendar expects timezone name in Region/City format.
/etc/localtime file itself doesn't container this data.
To figure the name out plugins/datetime/system-timezone.c code is searching in SYSTEM_ZONEINFODIR (/usr/share/zoneinfo) directory.
The timezone name is determined based on filename path with SYSTEM_ZONEINFODIR prefix cut.

there are multiple instances of the same timezone file under different names and subfolders in the SYSTEM_ZONEINFODIR folder.
I. e a timezone may have several names, i. e. files in that SYSTEM_ZONEINFODIR folder.
For example, /usr/share/zoneinfo/Navajo and /usr/share/zoneinfo/America/Denver are the same timezones.

In some operating systems /etc/localtime is a symlink to /usr/share/zoneinfo/Navajo which is the symlink to /usr/share/zoneinfo/America/Denver.
In other operating systems those may be hardlinks.
In third operating system those files might be just simple copies of each other.
Of course there might be a combination of all those scenarios.

The code in plugins/datetime/system-timezone.c does its best to determine timezone name by following links, comparing files content, etc.
It covers those different scenarios with sym-, hard- links, copied, etc described above.

This patch is for the case when all timezone files are copies.
Currently recursive_compare() in plugins/datetime/system-timezone.c gives up when it finds first copy of /etc/localtime under SYSTEM_ZONEINFODIR folder.
Which is unfortunately /usr/share/zoneinfo/Navajo in my example, not /usr/share/zoneinfo/America/Denver.
So upstream python code in cinnamon-setting calendar gets timezone name as Navajo, while it expects rather America/Denver.

Fix it by checking if timezone name has a slash "/" in its name.
If it doesn't then keep running recursive_compare() against SYSTEM_ZONEINFODIR (/usr/share/zoneinfo) directory to find a better name.

@timp87 timp87 force-pushed the system-timezone-copied-zone-files branch 2 times, most recently from ac05125 to d2f96d5 Compare October 10, 2024 20:45
@timp87 timp87 changed the title Do not accept timezone name if it's not in region/city format system-timezone: do not accept timezone name if it's not in region/city format Oct 10, 2024
@timp87 timp87 force-pushed the system-timezone-copied-zone-files branch 3 times, most recently from ebd9952 to 10505e3 Compare October 10, 2024 23:07
…/city format

`plugins/datetime/system-timezone.c` finds timezone name out based on system timezone config - `/etc/localtime` file.
Upstream python code in `cinnamon-setting calendar` expects timezone name in `Region/City` format.
`/etc/localtime` file itself doesn't container this data.
To figure the name out `plugins/datetime/system-timezone.c` code is searching in `SYSTEM_ZONEINFODIR` (/usr/share/zoneinfo) directory.
The timezone name is determined based on filename path with `SYSTEM_ZONEINFODIR` prefix cut.

there are multiple instances of the same timezone file under different names and subfolders in the `SYSTEM_ZONEINFODIR` folder.
I. e a timezone may have several names, i. e. files in that `SYSTEM_ZONEINFODIR` folder.
For example, `/usr/share/zoneinfo/Navajo` and `/usr/share/zoneinfo/America/Denver` are the same timezones.

In some operating systems `/etc/localtime` is a symlink to `/usr/share/zoneinfo/Navajo` which is the symlink to `/usr/share/zoneinfo/America/Denver`.
In other operating systems those may be hardlinks.
In third operating system those files might be just simple copies of each other.
Of course there might be a combination of all those scenarios.

The code in `plugins/datetime/system-timezone.c` does its best to determine timezone name by following links, comparing files content, etc.
It covers those different scenarios with sym-, hard- links, copied, etc described above.

This patch is for the case when all timezone files are copies.
Currently `recursive_compare()` in `plugins/datetime/system-timezone.c` gives up when it finds first copy of `/etc/localtime` under `SYSTEM_ZONEINFODIR` folder.
Which is unfortunately `/usr/share/zoneinfo/Navajo` in my example, not `/usr/share/zoneinfo/America/Denver`.
So upstream python code in `cinnamon-setting calendar` gets timezone name as `Navajo`, while it expects rather `America/Denver`.

Fix it by checking if timezone name has a slash "/" in its name.
If it doesn't then keep running `recursive_compare()` against `SYSTEM_ZONEINFODIR` (/usr/share/zoneinfo) directory to find a better name.
@timp87 timp87 force-pushed the system-timezone-copied-zone-files branch from 10505e3 to 6fbf813 Compare October 10, 2024 23:07
@timp87 timp87 changed the title system-timezone: do not accept timezone name if it's not in region/city format system-timezone: keep looking for timezone name if it's not in region/city format Oct 10, 2024
@timp87 timp87 changed the title system-timezone: keep looking for timezone name if it's not in region/city format system-timezone: keep looking for timezone name if it's not in Region/City format Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant