gdatetime-test-fail-0001.patch 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. From fc893fe975126ca7d5fcf76b66b5c0ccbd4128d5 Mon Sep 17 00:00:00 2001
  2. From: "Rebecca N. Palmer" <rebecca_palmer@zoho.com>
  3. Date: Fri, 11 Oct 2024 09:38:52 +0100
  4. Subject: [PATCH] gdatetime test: Do not assume PST8PDT was always exactly
  5. -8/-7
  6. In newer tzdata, it is an alias for America/Los_Angeles, which has a
  7. slightly different meaning: DST did not exist there before 1883. As a
  8. result, we can no longer hard-code the knowledge that interval 0 is
  9. standard time and interval 1 is summer time, and instead we need to look
  10. up the correct intervals from known timestamps.
  11. Resolves: https://gitlab.gnome.org/GNOME/glib/-/issues/3502
  12. Bug-Debian: https://bugs.debian.org/1084190
  13. [smcv: expand commit message, fix whitespace]
  14. Signed-off-by: Simon McVittie <smcv@debian.org>
  15. Upstream-Status: Backport
  16. [https://github.com/GNOME/glib/commit/c0619f08e6c608fd6464d2f0c6970ef0bbfb9ecf]
  17. Signed-off-by: Jinfeng Wang <jinfeng.wang.cn@windriver.com>
  18. ---
  19. glib/tests/gdatetime.c | 22 ++++++++++++++++------
  20. 1 file changed, 16 insertions(+), 6 deletions(-)
  21. diff --git a/glib/tests/gdatetime.c b/glib/tests/gdatetime.c
  22. index d46f653..2eefc41 100644
  23. --- a/glib/tests/gdatetime.c
  24. +++ b/glib/tests/gdatetime.c
  25. @@ -2930,6 +2930,7 @@ test_posix_parse (void)
  26. {
  27. GTimeZone *tz;
  28. GDateTime *gdt1, *gdt2;
  29. + gint i1, i2;
  30. /* Check that an unknown zone name falls back to UTC. */
  31. G_GNUC_BEGIN_IGNORE_DEPRECATIONS
  32. @@ -2953,16 +2954,25 @@ test_posix_parse (void)
  33. /* This fails rules_from_identifier on Unix (though not on Windows)
  34. * but passes anyway because PST8PDT is a zone name.
  35. + *
  36. + * Intervals i1 and i2 (rather than 0 and 1) are needed because in
  37. + * recent tzdata, PST8PDT may be an alias for America/Los_Angeles,
  38. + * and hence be aware that DST has not always existed.
  39. + * https://bugs.debian.org/1084190
  40. */
  41. tz = g_time_zone_new_identifier ("PST8PDT");
  42. g_assert_nonnull (tz);
  43. g_assert_cmpstr (g_time_zone_get_identifier (tz), ==, "PST8PDT");
  44. - g_assert_cmpstr (g_time_zone_get_abbreviation (tz, 0), ==, "PST");
  45. - g_assert_cmpint (g_time_zone_get_offset (tz, 0), ==, - 8 * 3600);
  46. - g_assert (!g_time_zone_is_dst (tz, 0));
  47. - g_assert_cmpstr (g_time_zone_get_abbreviation (tz, 1), ==, "PDT");
  48. - g_assert_cmpint (g_time_zone_get_offset (tz, 1), ==,- 7 * 3600);
  49. - g_assert (g_time_zone_is_dst (tz, 1));
  50. + /* a date in winter = non-DST */
  51. + i1 = g_time_zone_find_interval (tz, G_TIME_TYPE_STANDARD, 0);
  52. + /* approximately 6 months in seconds, i.e. a date in summer = DST */
  53. + i2 = g_time_zone_find_interval (tz, G_TIME_TYPE_DAYLIGHT, 15000000);
  54. + g_assert_cmpstr (g_time_zone_get_abbreviation (tz, i1), ==, "PST");
  55. + g_assert_cmpint (g_time_zone_get_offset (tz, i1), ==, - 8 * 3600);
  56. + g_assert (!g_time_zone_is_dst (tz, i1));
  57. + g_assert_cmpstr (g_time_zone_get_abbreviation (tz, i2), ==, "PDT");
  58. + g_assert_cmpint (g_time_zone_get_offset (tz, i2), ==,- 7 * 3600);
  59. + g_assert (g_time_zone_is_dst (tz, i2));
  60. g_time_zone_unref (tz);
  61. tz = g_time_zone_new_identifier ("PST8PDT6:32:15");