Menu

#8 Two birthdays with same name

pending-rejected
nobody
None
5
2012-02-13
2012-02-08
No

When there are two birthdays with the same name, both are diplayed in the list, but with the same date.

For instance, assuming my CSV file contains the following birthdates:

1979-02-23, Girlfriend
1979-03-08, Girlfriend

(Can't you have two ?...)

then I get the following birthday list;

23 february Girlfriend 15 Days, 33 Years
23 february Girlfriend 29 Days, 33 Years <-- note the mixup here

In fact, "name" is used as a key here, in open_window :

for delta_day in range(self.conf.firstday, self.conf.lastday + 1):
for name in self.addressbook.check_day(delta_day):
add_to_list(delta_day, name, fila)

Maybe using the name as the key was not a good idea. To avoid a complex rework, that function could be patched to check not only the name but also the date (month and day).

For instance:

def add_to_list(delta_day, name, fila):
# search for birthdate
for date, names in self.addressbook.bdays.items():
if name in names:
# Could be someone with the same name,
# check the date is same month and same day
day = datetime.date.today() + datetime.timedelta(delta_day)
if date[5:] == str(day)[5:]:
birthdate = date
break

birthdate = datetime.date(int(birthdate[:4]),
int(birthdate[5:7]),
int(birthdate[8:10]))

I'll try to submit this as a patch.

Discussion

  • Jérôme Lafréchoux

    Patch

     
  • Jérôme Lafréchoux

    My concern with this patch is that it could lead to a race condition if datetime.today() has changed since bdays_dict was filled. I'm afraid it could trigger a "birthdate used before assignment" error.

    I haven't thought about it too long, so I'm really not sure, but perhaps this race condition already existed and just led to a wrong delta days, like "in three days" instead of "in two days". I might be wrong.

     
  • Andreas Bresser

    Andreas Bresser - 2012-02-09

    Well, if your girlfriends both have the same name how do you know which one you have to wish a happy birthday?

     
  • Andreas Bresser

    Andreas Bresser - 2012-02-13
    • status: open --> pending-rejected
     

Log in to post a comment.