After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 300584 - Show age with birthday event in calendar
Show age with birthday event in calendar
Status: RESOLVED FIXED
Product: evolution
Classification: Applications
Component: Calendar
2.12.x
Other All
: Normal enhancement
: ---
Assigned To: Milan Crha
Evolution QA team
: 497423 502538 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2005-04-14 07:37 UTC by Adriaan Peeters
Modified: 2013-09-13 00:54 UTC
See Also:
GNOME target: ---
GNOME version: Unversioned Enhancement


Attachments
proposed patch (7.19 KB, patch)
2007-06-08 14:22 UTC, Milan Crha
needs-work Details | Review
proposed patch (7.54 KB, patch)
2007-06-14 10:23 UTC, Milan Crha
committed Details | Review
Evolution Birthday Calendar showing wrong ages. (664.10 KB, image/png)
2007-11-12 11:16 UTC, Simon Hepburn
  Details

Description Adriaan Peeters 2005-04-14 07:37:57 UTC
It would be nice to have the age shown with birthday events in the calendar.
Comment 1 André Klapper 2006-01-09 01:43:26 UTC
still in 2.5.4, retargetting
Comment 2 André Klapper 2007-06-05 18:01:56 UTC
something like that:
/* To translators: %s is the name of the person, and %d is the age (in years) */"

i feel free to assign this bug, feel free to reassign. neni zac. ;-)
Comment 3 Milan Crha 2007-06-08 14:22:00 UTC
Created attachment 89609 [details] [review]
proposed patch

for evolution;

It adds " (#)" after a summary text of the event if this event is in Birthday or Anniversary category, but only if start year minus actual year is bigger than 0. (Doesn't add value into the first occurrence.) It adds this "year info" into tooltip too. It only didn't work in list-view mode.

Andre: jo jo, diky moc :)
Comment 4 Srinivasa Ragavan 2007-06-09 20:34:38 UTC
Looks fine Milan. But doesn't it introduce warnings due to assigning to a const variable?
Comment 5 Milan Crha 2007-06-11 11:15:52 UTC
I tried this on actual trunk with and without a patch and no new warning there. So it may be fine. (changing 'needs-work' flag to 'none')
Comment 6 Srinivasa Ragavan 2007-06-11 13:48:43 UTC
ah! you are right. I was reviewing it and confused by the const assignment. Sorry for the spam. But Is it working for you? Im not able to get this working. The patch seems fine. But Im missing some thing to work.
Comment 7 Milan Crha 2007-06-11 14:04:33 UTC
Yes, it is :)
Add a person to local contact list, and setup there a Birthday to 12062007 and Anniversary 13062007, then go to Calendar, check "Birthdays & Anniversaries" and look on 12062007 or 13062007 will *not* add there any (#) as sufix, because that's a beginning ( "(0)" look strange), but in view of year 2008, it *will*.
Comment 8 Matthew Barnes 2007-06-11 21:20:12 UTC
+/* e_calendar_view_get_icalcomponent_summary returns summary of calcomp,
+ * and for type of birthday or anniversary it append number of years since
+ * beginning. In this case, the free_text is set to TRUE and caller need
+ * to g_free returned string, otherwise free_text is set to FALSE and
+ * returned value is owned by calcomp.
+ */
+
+const gchar *
+e_calendar_view_get_icalcomponent_summary (icalcomponent *icalcomp, gboolean *free_text)


Wouldn't it be better to just always return a newly-allocated string, rather than forcing the caller to fuss with deciding whether or not to free it?

Perhaps just build up a GString like so:

gchar *
e_calendar_view_get_icalcomponent_summary (icalcomponent *icalcomp)
{
	GString *string;

	g_return_val_if_fail (icalcomp != NULL, NULL);

	string = g_string_new (icalcomponent_get_summary (icalcomp));

	if (icalcomp_contains_category (icalcomp, _("Birthday")) ||
	    icalcomp_contains_category (icalcomp, _("Anniversary"))) {
		struct icaltimetype dtstart, dtnow;

		dtstart = icalcomponent_get_dtstamp (icalcomp);
		dtnow = icalcomponent_get_dtstart (icalcomp);

		if (dtnow.year - dtstart.year > 0)
			g_string_append_printf (
				string, " (%d)", dtnow.year - dtstart.year);
	}

	return g_string_free (string, FALSE);
}
Comment 9 Milan Crha 2007-06-12 09:01:05 UTC
I did it like this only because there are only two categories, for which is this relevant and for almost all events you don't need to allocate any extra memory, so it's "safer" for memory. It looks strange for me to always allocate memory when it is not necessary.
Comment 10 Gilles Dartiguelongue 2007-06-13 20:31:37 UTC
I tried this patch tonight but it doesn't seem to work. I have a bunch of contacts in the default local addressbook with either birthday or anniversary set and neither shows up.

What did I miss ?
Comment 11 Milan Crha 2007-06-14 06:31:11 UTC
You need to have checked that "Birthdays & Anniversaries" in a calendar tree under "Contacts" node to show this in calendar. Maybe this?
Comment 12 André Klapper 2007-06-14 06:41:04 UTC
it is checked, i cannot get it to work either. :-(

patch with debug output appreciated, because i want this feature :-)
Comment 13 André Klapper 2007-06-14 07:41:12 UTC
the year check does not match against the birthyear, but against the creation year of that contact in evo, it seems
Comment 14 Milan Crha 2007-06-14 10:23:36 UTC
Created attachment 89939 [details] [review]
proposed patch

for evolution;

second chance :) This works better.
Comment 15 André Klapper 2007-06-14 11:14:23 UTC
patch works fine here, i sometimes had problems (e.g. repainting issue when changing an anniversary by one year => not displayed in main window, but in mini calendar, like bug 353012, but in day view), and one big issue is still bug 339813 and bug 244382.

*every* person born before 1970 will be displayed as 37/38 years old. we need either a fix or a workaround (check year of birth and don't display age if born before 1970?) for this issue.

(cool, birthdays on a feb 29th actually work and get displayed on 28th in other years. nice, nice.)
Comment 16 André Klapper 2007-06-14 11:18:25 UTC
(correction: looks like the repainting issue would be fixed by the patch at bug 311098)
Comment 17 Gilles Dartiguelongue 2007-06-14 19:35:55 UTC
now it works for me too, thanks for the patch :)
Comment 18 Chenthill P 2007-07-08 20:28:36 UTC
Patch looks good. Committed to svn HEAD.
Comment 19 Simon Hepburn 2007-11-12 11:16:18 UTC
Created attachment 98969 [details]
Evolution Birthday Calendar showing wrong ages.

Still borked in Evolution 2.12.1

Attached screenshot shows 3 test contacts born 11th Nov in 1937, 1947 and 1957. Evolution Calendar erroneously shows all three having the same age. GBirthday shows their correct age as calculated from birthdates stored in EDS.
Comment 20 bmichels 2007-11-12 12:37:11 UTC
In my endeavors to find the source of this bug, I came across this
snippet from evolution-data-server/calendar/backends/contacts/e-cal-
backend-contacts.c:

static struct icaltimetype
cdate_to_icaltime (EContactDate *cdate)
{
        struct icaltimetype ret;

/*FIXME: this is a really _ugly_ (temporary) hack
 *      since several functions are still depending on the epoch,
 *      let entries start (earliest) at 19700101
 */
        ret.year = cdate->year >= 1970 ? cdate->year : 1970;
        ret.month = cdate->month;
        ret.day = cdate->day;
        ret.is_date = TRUE;
        ret.is_utc = FALSE;
        ret.zone = NULL;
        ret.is_daylight = FALSE;

        ret.hour = ret.minute = ret.second = 0;

        return ret;
}

The above "temporary hack" has been in there since revision 3557 in March 2004...
http://svn.gnome.org/viewvc/evolution-data-server/trunk/calendar/backends/contacts/e-cal-backend-contacts.c?view=log
Comment 21 Chenthill P 2007-11-16 11:56:00 UTC
I went through the bug 253885 for which the above patch was made. I think this part of the hack can be removed. Please commit the patch attached at http://bugzilla.gnome.org/show_bug.cgi?id=339813#c47.
Comment 22 Milan Crha 2007-11-16 12:13:21 UTC
Fix from the above link has been committed to trunk. Committed revision 8216.
And also to stable. Committed revision 8217.
Comment 23 André Klapper 2007-11-17 20:48:43 UTC
*** Bug 497423 has been marked as a duplicate of this bug. ***
Comment 24 André Klapper 2007-12-08 19:40:02 UTC
*** Bug 502538 has been marked as a duplicate of this bug. ***