[gnome-contacts/gnome-41] Ensure correct handling of February 2000 in birthday editor



commit 408da3487af0f7179e5bca8702a4e7ba4ef74fdc
Author: Charles Keepax <ckeepax gmail com>
Date:   Tue Sep 21 21:32:19 2021 +0100

    Ensure correct handling of February 2000 in birthday editor
    
    There is a third rule for leap year handling which is that years
    divisible by 400 are leap years. Normally this isn't a huge issue since
    it only happens every 400 years, but the year 2000 was one of those
    years which is well within the reasonable range of current birthdays and
    the current system will not accept the 29th of February 2000 as a valid
    date.

 src/contacts-editor-property.vala | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/src/contacts-editor-property.vala b/src/contacts-editor-property.vala
index 14fa933f..d03cde3b 100644
--- a/src/contacts-editor-property.vala
+++ b/src/contacts-editor-property.vala
@@ -104,8 +104,9 @@ public class Contacts.BirthdayEditor : Gtk.Dialog {
       if (month_combo.get_active () in month_of_31) {
         day_spin.set_range (1, 30);
       } else if (month_combo.get_active () == 1) {
-        if (year_spin.get_value_as_int () % 4 == 0 &&
-            year_spin.get_value_as_int () % 100 != 0) {
+        if (year_spin.get_value_as_int () % 400 == 0 ||
+            (year_spin.get_value_as_int () % 4 == 0 &&
+             year_spin.get_value_as_int () % 100 != 0)) {
           day_spin.set_range (1, 29);
         } else {
           day_spin.set_range (1, 28);


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