fix_day_and_night_calculation.patch 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. From f98836ef80afd511b9debc5d24cc570cd0f6ad20 Mon Sep 17 00:00:00 2001
  2. From: Mikhail Efremov <sem@altlinux.org>
  3. Date: Fri, 22 Nov 2019 18:11:26 +0300
  4. Subject: Fix day/night calculation (bug #16091)
  5. Time in the astronomical date given in local time, so parse it as
  6. local. Otherwise the day/night calculation is broken, we can't
  7. compare local and UTC time properly.
  8. This fixes commit 701da805ecf273f376dbae5003607746fad9d316.
  9. Signed-off-by: Sean Davis <smd.seandavis@gmail.com>
  10. ---
  11. panel-plugin/weather-parsers.c | 8 ++++----
  12. panel-plugin/weather-summary.c | 16 ++++++++--------
  13. panel-plugin/weather.c | 20 ++++++++++----------
  14. 3 files changed, 22 insertions(+), 22 deletions(-)
  15. diff --git a/panel-plugin/weather-parsers.c b/panel-plugin/weather-parsers.c
  16. index 109d726..786abf7 100644
  17. --- a/panel-plugin/weather-parsers.c
  18. +++ b/panel-plugin/weather-parsers.c
  19. @@ -445,28 +445,28 @@ parse_astro_time(xmlNode *cur_node)
  20. if (child_node->type == XML_ELEMENT_NODE) {
  21. if (NODE_IS_TYPE(child_node, "sunrise")) {
  22. sunrise = remove_timezone_offset(PROP(child_node, "time"));
  23. - astro->sunrise = parse_timestring(sunrise, NULL, FALSE);
  24. + astro->sunrise = parse_timestring(sunrise, NULL, TRUE);
  25. xmlFree(sunrise);
  26. sun_rises = TRUE;
  27. }
  28. if (NODE_IS_TYPE(child_node, "moonset")) {
  29. moonset = remove_timezone_offset(PROP(child_node, "time"));
  30. - astro->moonset = parse_timestring(moonset, NULL, FALSE);
  31. + astro->moonset = parse_timestring(moonset, NULL, TRUE);
  32. xmlFree(moonset);
  33. moon_sets = TRUE;
  34. }
  35. if (NODE_IS_TYPE(child_node, "sunset")) {
  36. sunset = remove_timezone_offset(PROP(child_node, "time"));
  37. - astro->sunset = parse_timestring(sunset, NULL, FALSE);
  38. + astro->sunset = parse_timestring(sunset, NULL, TRUE);
  39. xmlFree(sunset);
  40. sun_sets = TRUE;
  41. }
  42. if (NODE_IS_TYPE(child_node, "moonrise")) {
  43. moonrise = remove_timezone_offset(PROP(child_node, "time"));
  44. - astro->moonrise = parse_timestring(moonrise, NULL, FALSE);
  45. + astro->moonrise = parse_timestring(moonrise, NULL, TRUE);
  46. xmlFree(moonrise);
  47. moon_rises = TRUE;
  48. }
  49. diff --git a/panel-plugin/weather-summary.c b/panel-plugin/weather-summary.c
  50. index dbe3014..da12a5b 100644
  51. --- a/panel-plugin/weather-summary.c
  52. +++ b/panel-plugin/weather-summary.c
  53. @@ -417,12 +417,12 @@ create_summary_tab(plugin_data *data)
  54. value = g_strdup(_("\tSunset:\t\tThe sun never sets today.\n"));
  55. APPEND_TEXT_ITEM_REAL(value);
  56. } else {
  57. - sunrise = format_date(data->current_astro->sunrise, NULL, FALSE);
  58. + sunrise = format_date(data->current_astro->sunrise, NULL, TRUE);
  59. value = g_strdup_printf(_("\tSunrise:\t\t%s\n"), sunrise);
  60. g_free(sunrise);
  61. APPEND_TEXT_ITEM_REAL(value);
  62. - sunset = format_date(data->current_astro->sunset, NULL, FALSE);
  63. + sunset = format_date(data->current_astro->sunset, NULL, TRUE);
  64. value = g_strdup_printf(_("\tSunset:\t\t%s\n\n"), sunset);
  65. g_free(sunset);
  66. APPEND_TEXT_ITEM_REAL(value);
  67. @@ -445,12 +445,12 @@ create_summary_tab(plugin_data *data)
  68. g_strdup(_("\tMoonset:\tThe moon never sets today.\n"));
  69. APPEND_TEXT_ITEM_REAL(value);
  70. } else {
  71. - moonrise = format_date(data->current_astro->moonrise, NULL, FALSE);
  72. + moonrise = format_date(data->current_astro->moonrise, NULL, TRUE);
  73. value = g_strdup_printf(_("\tMoonrise:\t%s\n"), moonrise);
  74. g_free(moonrise);
  75. APPEND_TEXT_ITEM_REAL(value);
  76. - moonset = format_date(data->current_astro->moonset, NULL, FALSE);
  77. + moonset = format_date(data->current_astro->moonset, NULL, TRUE);
  78. value = g_strdup_printf(_("\tMoonset:\t%s\n"), moonset);
  79. g_free(moonset);
  80. APPEND_TEXT_ITEM_REAL(value);
  81. @@ -699,13 +699,13 @@ forecast_day_header_tooltip_text(xml_astro *astro)
  82. "Sunset: The sun never sets this day."
  83. "</small></tt>\n"));
  84. else {
  85. - sunrise = format_date(astro->sunrise, NULL, FALSE);
  86. + sunrise = format_date(astro->sunrise, NULL, TRUE);
  87. g_string_append_printf(text, _("<tt><small>"
  88. "Sunrise: %s"
  89. "</small></tt>\n"), sunrise);
  90. g_free(sunrise);
  91. - sunset = format_date(astro->sunset, NULL, FALSE);
  92. + sunset = format_date(astro->sunset, NULL, TRUE);
  93. g_string_append_printf(text, _("<tt><small>"
  94. "Sunset: %s"
  95. "</small></tt>\n\n"), sunset);
  96. @@ -732,13 +732,13 @@ forecast_day_header_tooltip_text(xml_astro *astro)
  97. "Moonset: The moon never sets this day."
  98. "</small></tt>\n"));
  99. else {
  100. - moonrise = format_date(astro->moonrise, NULL, FALSE);
  101. + moonrise = format_date(astro->moonrise, NULL, TRUE);
  102. g_string_append_printf(text, _("<tt><small>"
  103. "Moonrise: %s"
  104. "</small></tt>\n"), moonrise);
  105. g_free(moonrise);
  106. - moonset = format_date(astro->moonset, NULL, FALSE);
  107. + moonset = format_date(astro->moonset, NULL, TRUE);
  108. g_string_append_printf(text, _("<tt><small>"
  109. "Moonset: %s"
  110. "</small></tt>"), moonset);
  111. diff --git a/panel-plugin/weather.c b/panel-plugin/weather.c
  112. index 7d79566..11f6f6f 100644
  113. --- a/panel-plugin/weather.c
  114. +++ b/panel-plugin/weather.c
  115. @@ -1115,8 +1115,8 @@ write_cache_file(plugin_data *data)
  116. if (G_UNLIKELY(astro == NULL))
  117. continue;
  118. value = format_date(astro->day, "%Y-%m-%d", TRUE);
  119. - start = format_date(astro->sunrise, date_format, FALSE);
  120. - end = format_date(astro->sunset, date_format, FALSE);
  121. + start = format_date(astro->sunrise, date_format, TRUE);
  122. + end = format_date(astro->sunset, date_format, TRUE);
  123. g_string_append_printf(out, "[astrodata%d]\n", i);
  124. CACHE_APPEND("day=%s\n", value);
  125. CACHE_APPEND("sunrise=%s\n", start);
  126. @@ -1129,8 +1129,8 @@ write_cache_file(plugin_data *data)
  127. g_free(start);
  128. g_free(end);
  129. - start = format_date(astro->moonrise, date_format, FALSE);
  130. - end = format_date(astro->moonset, date_format, FALSE);
  131. + start = format_date(astro->moonrise, date_format, TRUE);
  132. + end = format_date(astro->moonset, date_format, TRUE);
  133. CACHE_APPEND("moonrise=%s\n", start);
  134. CACHE_APPEND("moonset=%s\n", end);
  135. CACHE_APPEND("moon_never_rises=%s\n",
  136. @@ -1303,10 +1303,10 @@ read_cache_file(plugin_data *data)
  137. astro->day = parse_timestring(timestring, "%Y-%m-%d", TRUE);
  138. g_free(timestring);
  139. CACHE_READ_STRING(timestring, "sunrise");
  140. - astro->sunrise = parse_timestring(timestring, NULL, FALSE);
  141. + astro->sunrise = parse_timestring(timestring, NULL, TRUE);
  142. g_free(timestring);
  143. CACHE_READ_STRING(timestring, "sunset");
  144. - astro->sunset = parse_timestring(timestring, NULL, FALSE);
  145. + astro->sunset = parse_timestring(timestring, NULL, TRUE);
  146. g_free(timestring);
  147. astro->sun_never_rises =
  148. g_key_file_get_boolean(keyfile, group, "sun_never_rises", NULL);
  149. @@ -1314,10 +1314,10 @@ read_cache_file(plugin_data *data)
  150. g_key_file_get_boolean(keyfile, group, "sun_never_sets", NULL);
  151. CACHE_READ_STRING(timestring, "moonrise");
  152. - astro->moonrise = parse_timestring(timestring, NULL, FALSE);
  153. + astro->moonrise = parse_timestring(timestring, NULL, TRUE);
  154. g_free(timestring);
  155. CACHE_READ_STRING(timestring, "moonset");
  156. - astro->moonset = parse_timestring(timestring, NULL, FALSE);
  157. + astro->moonset = parse_timestring(timestring, NULL, TRUE);
  158. g_free(timestring);
  159. CACHE_READ_STRING(astro->moon_phase, "moon_phase");
  160. astro->moon_never_rises =
  161. @@ -1731,9 +1731,9 @@ weather_get_tooltip_text(const plugin_data *data)
  162. sunval = g_strdup(_("The sun never sets today."));
  163. } else {
  164. sunrise = format_date(data->current_astro->sunrise,
  165. - "%H:%M:%S", FALSE);
  166. + "%H:%M:%S", TRUE);
  167. sunset = format_date(data->current_astro->sunset,
  168. - "%H:%M:%S", FALSE);
  169. + "%H:%M:%S", TRUE);
  170. sunval =
  171. g_strdup_printf(_("The sun rises at %s and sets at %s."),
  172. sunrise, sunset);
  173. --
  174. cgit v1.2.3