[evolution-data-server] I#368 - Calendar: X-EVOLUTION-ENDDATE can be calculated incorrectly



commit 60d1452d7fe030163a8b7b660bab262930a5d0f4
Author: Milan Crha <mcrha redhat com>
Date:   Mon Dec 13 13:46:52 2021 +0100

    I#368 - Calendar: X-EVOLUTION-ENDDATE can be calculated incorrectly
    
    Closes https://gitlab.gnome.org/GNOME/evolution-data-server/-/issues/368

 CMakeLists.txt                     | 8 ++++++++
 config.h.in                        | 3 +++
 src/calendar/libecal/e-cal-recur.c | 9 +++++++++
 3 files changed, 20 insertions(+)
---
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7d3aa14f7..da32d3a40 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -145,6 +145,7 @@ include(CheckCSourceRuns)
 include(CheckFunctionExists)
 include(CheckIncludeFile)
 include(CheckLibraryExists)
+include(CheckTypeSize)
 
 # Project custom modules
 include(PrintableOptions)
@@ -977,6 +978,13 @@ if(ENABLE_VALA_BINDINGS)
 
 endif(ENABLE_VALA_BINDINGS)
 
+set(CMAKE_EXTRA_INCLUDE_FILES "time.h")
+CHECK_TYPE_SIZE("time_t" SIZEOF_TIME_T)
+if("${SIZEOF_TIME_T}" STREQUAL "4")
+       set(HAVE_32BIT_TIME_T 1)
+endif("${SIZEOF_TIME_T}" STREQUAL "4")
+unset(CMAKE_EXTRA_INCLUDE_FILES)
+
 # Generate the ${PROJECT_NAME}-config.h file
 CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/config.h.in ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config.h)
 
diff --git a/config.h.in b/config.h.in
index dfe787d19..4e79549ab 100644
--- a/config.h.in
+++ b/config.h.in
@@ -202,3 +202,6 @@
 
 /* Whether glib provides GPowerProfileMonitor */
 #cmakedefine HAVE_GPOWERPROFILEMONITOR 1
+
+/* Defined, when time_t is of the 32bit size */
+#cmakedefine HAVE_32BIT_TIME_T 1
diff --git a/src/calendar/libecal/e-cal-recur.c b/src/calendar/libecal/e-cal-recur.c
index a912fc1f4..c23cc59f4 100644
--- a/src/calendar/libecal/e-cal-recur.c
+++ b/src/calendar/libecal/e-cal-recur.c
@@ -900,10 +900,14 @@ e_cal_recur_generate_instances_sync (ICalComponent *icalcomp,
  *     spec.
  */
 
+#ifdef HAVE_32BIT_TIME_T
 /* This is the maximum year we will go up to (inclusive). Since we use time_t
  * values we can't go past 2037 anyway, and some of our VTIMEZONEs may stop
  * at 2037 as well. */
 #define MAX_YEAR       2037
+#else
+#define MAX_YEAR       9999
+#endif
 
 /* Define this for some debugging output. */
 #if 0
@@ -4859,6 +4863,11 @@ e_cal_recur_set_rule_end_date (ICalProperty *prop,
        const gchar *xname;
        gchar *end_date_string;
 
+       if (end_date <= 0) {
+               i_cal_property_remove_parameter_by_name (prop, E_CAL_EVOLUTION_ENDDATE_PARAMETER);
+               return;
+       }
+
        /* We save the value as a UTC DATE-TIME. */
        utc_zone = i_cal_timezone_get_utc_timezone ();
        icaltime = i_cal_time_new_from_timet_with_zone (end_date, FALSE, utc_zone);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]