gdatetime-test-fail-0002.patch 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. From 1110f463fe084ba2675e044be2e045f7c0224a7f Mon Sep 17 00:00:00 2001
  2. From: Simon McVittie <smcv@debian.org>
  3. Date: Fri, 18 Oct 2024 11:03:19 +0100
  4. Subject: [PATCH] gdatetime test: Try to make PST8PDT test more obviously
  5. correct
  6. Instead of using timestamp 0 as a magic number (in this case interpreted
  7. as 1970-01-01T00:00:00-08:00), calculate a timestamp from a recent
  8. year/month/day in winter, in this case 2024-01-01T00:00:00-08:00.
  9. Similarly, instead of using a timestamp 15 million seconds later
  10. (1970-06-23T15:40:00-07:00), calculate a timestamp from a recent
  11. year/month/day in summer, in this case 2024-07-01T00:00:00-07:00.
  12. Signed-off-by: Simon McVittie <smcv@debian.org>
  13. Upstream-Status: Backport
  14. [https://github.com/GNOME/glib/commit/30e9cfa5733003cd1079e0e9e8a4bff1a191171a]
  15. Signed-off-by: Jinfeng Wang <jinfeng.wang.cn@windriver.com>
  16. ---
  17. glib/tests/gdatetime.c | 15 +++++++--------
  18. 1 file changed, 7 insertions(+), 8 deletions(-)
  19. diff --git a/glib/tests/gdatetime.c b/glib/tests/gdatetime.c
  20. index 2eefc41..728b873 100644
  21. --- a/glib/tests/gdatetime.c
  22. +++ b/glib/tests/gdatetime.c
  23. @@ -2954,19 +2954,16 @@ test_posix_parse (void)
  24. /* This fails rules_from_identifier on Unix (though not on Windows)
  25. * but passes anyway because PST8PDT is a zone name.
  26. - *
  27. - * Intervals i1 and i2 (rather than 0 and 1) are needed because in
  28. - * recent tzdata, PST8PDT may be an alias for America/Los_Angeles,
  29. - * and hence be aware that DST has not always existed.
  30. - * https://bugs.debian.org/1084190
  31. */
  32. tz = g_time_zone_new_identifier ("PST8PDT");
  33. g_assert_nonnull (tz);
  34. g_assert_cmpstr (g_time_zone_get_identifier (tz), ==, "PST8PDT");
  35. /* a date in winter = non-DST */
  36. - i1 = g_time_zone_find_interval (tz, G_TIME_TYPE_STANDARD, 0);
  37. - /* approximately 6 months in seconds, i.e. a date in summer = DST */
  38. - i2 = g_time_zone_find_interval (tz, G_TIME_TYPE_DAYLIGHT, 15000000);
  39. + gdt1 = g_date_time_new (tz, 2024, 1, 1, 0, 0, 0);
  40. + i1 = g_time_zone_find_interval (tz, G_TIME_TYPE_STANDARD, g_date_time_to_unix (gdt1));
  41. + /* a date in summer = DST */
  42. + gdt2 = g_date_time_new (tz, 2024, 7, 1, 0, 0, 0);
  43. + i2 = g_time_zone_find_interval (tz, G_TIME_TYPE_DAYLIGHT, g_date_time_to_unix (gdt2));
  44. g_assert_cmpstr (g_time_zone_get_abbreviation (tz, i1), ==, "PST");
  45. g_assert_cmpint (g_time_zone_get_offset (tz, i1), ==, - 8 * 3600);
  46. g_assert (!g_time_zone_is_dst (tz, i1));
  47. @@ -2974,6 +2971,8 @@ test_posix_parse (void)
  48. g_assert_cmpint (g_time_zone_get_offset (tz, i2), ==,- 7 * 3600);
  49. g_assert (g_time_zone_is_dst (tz, i2));
  50. g_time_zone_unref (tz);
  51. + g_date_time_unref (gdt1);
  52. + g_date_time_unref (gdt2);
  53. tz = g_time_zone_new_identifier ("PST8PDT6:32:15");
  54. #ifdef G_OS_WIN32