gtimezone: Add g_time_zone_get_identifier() accessor

This is a non-trivial accessor which gets the identifier string used to
create the GTimeZone — unless the string passed to g_time_zone_new() was
invalid, in which case the identifier will be `UTC`.

Implementing this required reworking how timezone information was loaded
so that the tz->name is always set at the same time as tz->t_info, so
they are in sync. Previously, the tz->name was unconditionally set to
whatever was passed to g_time_zone_new(), and then not updated if the
tz->t_info was eventually set to the default UTC information.

This includes tests for the new g_time_zone_get_identifier() API, and
for the g_date_time_get_timezone() API added in the previous commit.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://bugzilla.gnome.org/show_bug.cgi?id=795165
This commit is contained in:
Philip Withnall
2018-04-11 15:59:29 +01:00
parent 9ddd17d304
commit 8945227743
4 changed files with 217 additions and 35 deletions

View File

@@ -1653,6 +1653,7 @@ GTimeType
g_time_zone_find_interval
g_time_zone_adjust_time
<SUBSECTION>
g_time_zone_get_identifier
g_time_zone_get_abbreviation
g_time_zone_get_offset
g_time_zone_is_dst