diff options
author | Damon Chaplin <damon@ximian.com> | 2001-07-11 11:56:03 +0800 |
---|---|---|
committer | Damon Chaplin <damon@src.gnome.org> | 2001-07-11 11:56:03 +0800 |
commit | 0e6d346872289d1ee71cb7b1092b5229b11dab3e (patch) | |
tree | 588b9cbac780c577af5c56d020c98f2f3822b38f /calendar/cal-util/timeutil.h | |
parent | 552d3501e9bf05d42ce6f342e85a526a1cea702c (diff) | |
download | gsoc2013-evolution-0e6d346872289d1ee71cb7b1092b5229b11dab3e.tar.gz gsoc2013-evolution-0e6d346872289d1ee71cb7b1092b5229b11dab3e.tar.zst gsoc2013-evolution-0e6d346872289d1ee71cb7b1092b5229b11dab3e.zip |
more timezone updates. I'm pretty much done with the calendar code now,
2001-07-10 Damon Chaplin <damon@ximian.com>
* gui/calendar-model.c:
* gui/e-calendar-table.c:
* gui/e-day-view-main-item.c:
* gui/e-day-view-top-item.c:
* gui/e-day-view.[hc]:
* gui/e-week-view.c:
* gui/gnome-cal.c:
* gui/print.c:
* gui/dialogs/cal-prefs-dialog.c:
* gui/dialogs/comp-editor-util.c:
* gui/dialogs/event-page.c:
* pcs/cal-backend-file.c:
* pcs/query.c:
* cal-util/cal-component.[hc]:
* cal-util/cal-recur.c:
* cal-util/timeutil.[hc]:
* cal-client/cal-client.[hc]: more timezone updates. I'm pretty much
done with the calendar code now, except for alarms and conduits,
which Federico and JP know more about. And there are a couple of
other minor things to fix. But it is still pretty buggy.
svn path=/trunk/; revision=10984
Diffstat (limited to 'calendar/cal-util/timeutil.h')
-rw-r--r-- | calendar/cal-util/timeutil.h | 123 |
1 files changed, 89 insertions, 34 deletions
diff --git a/calendar/cal-util/timeutil.h b/calendar/cal-util/timeutil.h index b01747ecfc..3679173572 100644 --- a/calendar/cal-util/timeutil.h +++ b/calendar/cal-util/timeutil.h @@ -2,10 +2,10 @@ * * Copyright (C) 1998 The Free Software Foundation * Copyright (C) 2000 Ximian, Inc. - * Copyright (C) 2000 Ximian, Inc. * * Authors: Federico Mena <federico@ximian.com> * Miguel de Icaza <miguel@ximian.com> + * Damon Chaplin <damon@ximian.com> */ #ifndef TIMEUTIL_H @@ -14,52 +14,107 @@ #include <time.h> #include <ical.h> +#include <glib.h> -char *isodate_from_time_t (time_t t); -time_t time_from_isodate (const char *str); +/************************************************************************** + * General time functions. + **************************************************************************/ -time_t time_add_minutes (time_t time, int minutes); -time_t time_add_day (time_t time, int days); -time_t time_add_week (time_t time, int weeks); -time_t time_add_month (time_t time, int months); -time_t time_add_year (time_t time, int years); +/* Returns the number of days in the month. Year is the normal year, e.g. 2001. + Month is 0 (Jan) to 11 (Dec). */ +int time_days_in_month (int year, int month); +/* Returns the 1-based day number within the year of the specified date. + Year is the normal year, e.g. 2001. Month is 0 to 11. */ +int time_day_of_year (int day, int month, int year); -/* Returns the number of days in the specified month. Years are full years - (starting from year 1). Months are in [0, 11]. */ -int time_days_in_month (int year, int month); +/* Returns the day of the week for the specified date, 0 (Sun) to 6 (Sat). + For the days that were removed on the Gregorian reformation, it returns + Thursday. Year is the normal year, e.g. 2001. Month is 0 to 11. */ +int time_day_of_week (int day, int month, int year); -/* Converts the specified date to a time_t at the start of the specified day. - Years are full years (starting from year 1). Months are in [0, 11]. - Days are 1-based. */ -time_t time_from_day (int year, int month, int day); +/* Returns whether the specified year is a leap year. Year is the normal year, + e.g. 2001. */ +gboolean time_is_leap_year (int year); -/* For the functions below, time ranges are considered to contain the start - time, but not the end time. */ +/* Returns the number of leap years since year 1 up to (but not including) the + specified year. Year is the normal year, e.g. 2001. */ +int time_leap_years_up_to (int year); -/* These two functions take a time value and return the beginning or end of - the corresponding year, respectively. */ -time_t time_year_begin (time_t t); -time_t time_year_end (time_t t); +/* Convert to or from an ISO 8601 representation of a time, in UTC, + e.g. "20010708T183000Z". */ +char *isodate_from_time_t (time_t t); +time_t time_from_isodate (const char *str); -/* These two functions take a time value and return the beginning or end of - the corresponding month, respectively. */ -time_t time_month_begin (time_t t); -time_t time_month_end (time_t t); -/* These functions take a time value and return the beginning or end of the - corresponding week, respectively. week_start_day should use the same values +/************************************************************************** + * time_t manipulation functions. + * + * NOTE: these use the Unix timezone functions like mktime() and localtime() + * and so should not be used in Evolution. New Evolution code should use + * icaltimetype values rather than time_t values wherever possible. + **************************************************************************/ + +/* Add or subtract a number of days, weeks or months. */ +time_t time_add_day (time_t time, int days); +time_t time_add_week (time_t time, int weeks); +time_t time_add_month (time_t time, int months); + +/* Returns the beginning of the year or month. */ +time_t time_year_begin (time_t t); +time_t time_month_begin (time_t t); + +/* Returns the beginning of the week. week_start_day should use the same values as mktime(), i.e. 0 (Sun) to 6 (Sat). */ -time_t time_week_begin (time_t t, int week_start_day); -time_t time_week_end (time_t t, int week_start_day); +time_t time_week_begin (time_t t, int week_start_day); -/* These two functions take a time value and return the beginning or end of - the corresponding day, respectively. */ -time_t time_day_begin (time_t t); -time_t time_day_end (time_t t); +/* Returns the beginning or end of the day. */ +time_t time_day_begin (time_t t); +time_t time_day_end (time_t t); -void print_time_t (time_t t); + +/************************************************************************** + * time_t manipulation functions, using timezones in libical. + * + * NOTE: these are only here to make the transition to the timezone + * functions easier. New code should use icaltimetype values rather than + * time_t values wherever possible. + **************************************************************************/ + +/* Adds or subtracts a number of days to/from the given time_t value, using + the given timezone. */ +time_t time_add_day_with_zone (time_t time, int days, icaltimezone *zone); + +/* Adds or subtracts a number of weeks to/from the given time_t value, using + the given timezone. */ +time_t time_add_week_with_zone (time_t time, int weeks, icaltimezone *zone); + +/* Adds or subtracts a number of months to/from the given time_t value, using + the given timezone. */ +time_t time_add_month_with_zone (time_t time, int months, icaltimezone *zone); + +/* Returns the start of the year containing the given time_t, using the given + timezone. */ +time_t time_year_begin_with_zone (time_t time, icaltimezone *zone); + +/* Returns the start of the month containing the given time_t, using the given + timezone. */ +time_t time_month_begin_with_zone (time_t time, icaltimezone *zone); + +/* Returns the start of the week containing the given time_t, using the given + timezone. week_start_day should use the same values as mktime(), + i.e. 0 (Sun) to 6 (Sat). */ +time_t time_week_begin_with_zone (time_t time, int week_start_day, + icaltimezone *zone); + +/* Returns the start of the day containing the given time_t, using the given + timezone. */ +time_t time_day_begin_with_zone (time_t time, icaltimezone *zone); + +/* Returns the end of the day containing the given time_t, using the given + timezone. (The end of the day is the start of the next day.) */ +time_t time_day_end_with_zone (time_t time, icaltimezone *zone); #endif |