system-timezone: keep looking for timezone name if it's not in Region/City format #400
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 inRegion/City
format./etc/localtime
file itself doesn't container this data.To figure the name out
plugins/datetime/system-timezone.c
code is searching inSYSTEM_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()
inplugins/datetime/system-timezone.c
gives up when it finds first copy of/etc/localtime
underSYSTEM_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 asNavajo
, while it expects ratherAmerica/Denver
.Fix it by checking if timezone name has a slash "/" in its name.
If it doesn't then keep running
recursive_compare()
againstSYSTEM_ZONEINFODIR
(/usr/share/zoneinfo) directory to find a better name.