From 701cbac178b95c516269e8f908c69387745499ba Mon Sep 17 00:00:00 2001 From: JP Rosevear Date: Fri, 8 Sep 2000 15:37:37 +0000 Subject: New function that compares only the dates, not the times as well 2000-09-08 JP Rosevear * src/libical/icaltime.c (icaltime_compare_date_only): New function that compares only the dates, not the times as well * src/libical/icaltime.h: Add prototype svn path=/trunk/; revision=5260 --- libical/ChangeLog | 7 +++++++ libical/src/libical/icaltime.c | 17 +++++++++++++++++ libical/src/libical/icaltime.h | 1 + 3 files changed, 25 insertions(+) (limited to 'libical') diff --git a/libical/ChangeLog b/libical/ChangeLog index 1fec1bcc29..b256f7641a 100644 --- a/libical/ChangeLog +++ b/libical/ChangeLog @@ -1,3 +1,10 @@ +2000-09-08 JP Rosevear + + * src/libical/icaltime.c (icaltime_compare_date_only): New + function that compares only the dates, not the times as well + + * src/libical/icaltime.h: Add prototype + 2000-09-01 JP Rosevear * configure.in: We don't need AC_PROG_RANLIB and diff --git a/libical/src/libical/icaltime.c b/libical/src/libical/icaltime.c index 6f17278bde..6d651922d5 100644 --- a/libical/src/libical/icaltime.c +++ b/libical/src/libical/icaltime.c @@ -180,3 +180,20 @@ int icaltime_compare(struct icaltimetype a,struct icaltimetype b) } } + +int icaltime_compare_date_only(struct icaltimetype a, struct icaltimetype b) +{ + time_t t1 = icaltime_as_timet(a); + time_t t2 = icaltime_as_timet(b); + + if (a.year == b.year && a.month == b.month && a.day == b.day) { + return 0; + } + + if (t1 > t2) { + return 1; + } else if (t1 < t2) { + return -1; + } +} + diff --git a/libical/src/libical/icaltime.h b/libical/src/libical/icaltime.h index 64eaee0431..6c5b653c23 100644 --- a/libical/src/libical/icaltime.h +++ b/libical/src/libical/icaltime.h @@ -65,6 +65,7 @@ short icaltime_week_number(short day_of_month, short month, short year); struct icaltimetype icaltime_from_week_number(short week_number, short year); int icaltime_compare(struct icaltimetype a,struct icaltimetype b); +int icaltime_compare_date_only(struct icaltimetype a, struct icaltimetype b); short icaltime_days_in_month(short month,short year); -- cgit v1.2.3