e-cal-time-util

e-cal-time-util

Functions

Description

Functions

time_days_in_month ()

gint
time_days_in_month (gint year,
                    gint month);

Returns the number of days in the month. Year is the normal year, e.g. 2001. Month is 0 (Jan) to 11 (Dec).

Parameters

year

The year.

 

month

The month.

 

Returns

number of days in the given month/year.


time_day_of_year ()

gint
time_day_of_year (gint day,
                  gint month,
                  gint year);

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.

Parameters

day

The day.

 

month

The month.

 

year

The year.

 

Returns

the day of the year.


time_day_of_week ()

gint
time_day_of_week (gint day,
                  gint month,
                  gint year);

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.

Parameters

day

The day.

 

month

The month.

 

year

The year.

 

Returns

the day of the week for the given date.


time_is_leap_year ()

gboolean
time_is_leap_year (gint year);

Returns whether the specified year is a leap year. Year is the normal year, e.g. 2001.

Parameters

year

The year.

 

Returns

TRUE if the year is leap, FALSE if not.


time_leap_years_up_to ()

gint
time_leap_years_up_to (gint year);

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.

Parameters

year

The year.

 

Returns

number of leap years.


isodate_from_time_t ()

gchar *
isodate_from_time_t (time_t t);

Creates an ISO 8601 UTC representation from a time value.

Parameters

t

A time value.

 

Returns

String with the ISO 8601 representation of the UTC time.


time_from_isodate ()

time_t
time_from_isodate (const gchar *str);

Converts an ISO 8601 UTC time string into a time_t value.

Parameters

str

Date/time value in ISO 8601 format.

 

Returns

Time_t corresponding to the specified ISO string. Note that we only allow UTC times at present.


time_add_day ()

time_t
time_add_day (time_t time,
              gint days);

Adds a day onto the time, using local time. Note that if clocks go forward due to daylight savings time, there are some non-existent local times, so the hour may be changed to make it a valid time. This also means that it may not be wise to keep calling time_add_day() to step through a certain period - if the hour gets changed to make it valid time, any further calls to time_add_day() will also return this hour, which may not be what you want.

Parameters

time

A time_t value.

 

days

Number of days to add.

 

Returns

a time_t value containing time plus the days added.


time_add_week ()

time_t
time_add_week (time_t time,
               gint weeks);

Adds the given number of weeks to a time value.

Parameters

time

A time_t value.

 

weeks

Number of weeks to add.

 

Returns

a time_t value containing time plus the weeks added.


time_day_begin ()

time_t
time_day_begin (time_t t);

Returns the start of the day, according to the local time.

Parameters

t

A time_t value.

 

Returns

the time corresponding to the beginning of the day.


time_day_end ()

time_t
time_day_end (time_t t);

Returns the end of the day, according to the local time.

Parameters

t

A time_t value.

 

Returns

the time corresponding to the end of the day.


time_add_day_with_zone ()

time_t
time_add_day_with_zone (time_t time,
                        gint days,
                        const ICalTimezone *zone);

Adds or subtracts a number of days to/from the given time_t value, using the given timezone. NOTE: this function is only here to make the transition to the timezone functions easier. New code should use ICalTime values and i_cal_time_adjust() to add or subtract days, hours, minutes & seconds.

Parameters

time

A time_t value.

 

days

Number of days to add.

 

zone

Timezone to use.

 

Returns

a time_t value containing time plus the days added.


time_add_week_with_zone ()

time_t
time_add_week_with_zone (time_t time,
                         gint weeks,
                         const ICalTimezone *zone);

Adds or subtracts a number of weeks to/from the given time_t value, using the given timezone. NOTE: this function is only here to make the transition to the timezone functions easier. New code should use ICalTime values and i_cal_time_adjust() to add or subtract days, hours, minutes & seconds.

Parameters

time

A time_t value.

 

weeks

Number of weeks to add.

 

zone

Timezone to use.

 

Returns

a time_t value containing time plus the weeks added.


time_add_month_with_zone ()

time_t
time_add_month_with_zone (time_t time,
                          gint months,
                          const ICalTimezone *zone);

Adds or subtracts a number of months to/from the given time_t value, using the given timezone.

If the day would be off the end of the month (e.g. adding 1 month to 30th January, would lead to an invalid day, 30th February), it moves it down to the last day in the month, e.g. 28th Feb (or 29th in a leap year.)

NOTE: this function is only here to make the transition to the timezone functions easier. New code should use ICalTime values and i_cal_time_adjust() to add or subtract days, hours, minutes & seconds.

Parameters

time

A time_t value.

 

months

Number of months to add.

 

zone

Timezone to use.

 

Returns

a time_t value containing time plus the months added.


time_year_begin_with_zone ()

time_t
time_year_begin_with_zone (time_t time,
                           const ICalTimezone *zone);

Returns the start of the year containing the given time_t, using the given timezone. NOTE: this function is only here to make the transition to the timezone functions easier. New code should use ICalTime values and i_cal_time_adjust() to add or subtract days, hours, minutes & seconds.

Parameters

time

A time_t value.

 

zone

Timezone to use.

 

Returns

the beginning of the year.


time_month_begin_with_zone ()

time_t
time_month_begin_with_zone (time_t time,
                            const ICalTimezone *zone);

Returns the start of the month containing the given time_t, using the given timezone. NOTE: this function is only here to make the transition to the timezone functions easier. New code should use ICalTime values and i_cal_time_adjust() to add or subtract days, hours, minutes & seconds.

Parameters

time

A time_t value.

 

zone

Timezone to use.

 

Returns

the beginning of the month.


time_week_begin_with_zone ()

time_t
time_week_begin_with_zone (time_t time,
                           gint week_start_day,
                           const 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). NOTE: this function is only here to make the transition to the timezone functions easier. New code should use ICalTime values and i_cal_time_adjust() to add or subtract days, hours, minutes & seconds.

Parameters

time

A time_t value.

 

week_start_day

Day to use as the starting of the week.

 

zone

Timezone to use.

 

Returns

the beginning of the week.


time_day_begin_with_zone ()

time_t
time_day_begin_with_zone (time_t time,
                          const ICalTimezone *zone);

Returns the start of the day containing the given time_t, using the given timezone. NOTE: this function is only here to make the transition to the timezone functions easier. New code should use ICalTime values and i_cal_time_adjust() to add or subtract days, hours, minutes & seconds.

Parameters

time

A time_t value.

 

zone

Timezone to use.

 

Returns

the beginning of the day.


time_day_end_with_zone ()

time_t
time_day_end_with_zone (time_t time,
                        const 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.) NOTE: this function is only here to make the transition to the timezone functions easier. New code should use ICalTime values and i_cal_time_adjust() to add or subtract days, hours, minutes & seconds.

Parameters

time

A time_t value.

 

zone

Timezone to use.

 

Returns

the end of the day.


time_to_gdate_with_zone ()

void
time_to_gdate_with_zone (GDate *date,
                         time_t time,
                         const ICalTimezone *zone);

Converts a time_t value to a GDate structure using the specified timezone. This is analogous to g_date_set_time() but takes the timezone into account.

Parameters

date

Destination GDate value.

 

time

A time value.

 

zone

Desired timezone for destination date , or NULL if the UTC timezone is desired.

[nullable]

e_cal_util_icaltime_to_tm ()

struct tm
e_cal_util_icaltime_to_tm (const ICalTime *itt);

Converts an ICalTime into a GLibc's struct tm.

Parameters

itt

An ICalTime

 

Returns

The converted time as a struct tm. All fields will be set properly except for tm.tm_yday.

Since: 2.22


e_cal_util_icaltime_to_tm_with_zone ()

struct tm
e_cal_util_icaltime_to_tm_with_zone (const ICalTime *itt,
                                     const ICalTimezone *from_zone,
                                     const ICalTimezone *to_zone);

Converts a time value from one timezone to another, and returns a struct tm representation of the time.

Parameters

itt

A time value.

 

from_zone

Source timezone.

 

to_zone

Destination timezone.

 

Returns

The converted time as a struct tm. All fields will be set properly except for tm.tm_yday.

Since: 2.22


e_cal_util_tm_to_icaltime ()

ICalTime *
e_cal_util_tm_to_icaltime (struct tm *tm,
                           gboolean is_date);

Converts a struct tm into an ICalTime. Free the returned object with g_object_unref(), when no longer needed.

Parameters

tm

A struct tm.

 

is_date

Whether the given time is a date only or not.

 

Returns

The converted time as an ICalTime.

[transfer full]

Since: 2.22


e_cal_util_guess_timezone ()

ICalTimezone *
e_cal_util_guess_timezone (const gchar *tzid);

Tries to match the tzid with a built-in iCal timezone.

Whenever possible, the timezone should be taken from the timezone cache or the VCALENDAR component the owner component belongs to, this should be used just as the last resort when such time zone could not be found.

Parameters

tzid

a time zone ID

 

Returns

matching built-in ICalTimezone for the tzid , or NULL, when could not be found.

[nullable][transfer none]

Since: 3.58


e_cal_util_comp_time_to_zone ()

time_t
e_cal_util_comp_time_to_zone (ICalComponent *icomp,
                              ICalPropertyKind prop_kind,
                              ICalTimezone *to_zone,
                              ICalComponent *vcalendar,
                              ETimezoneCache *tz_cache,
                              ICalTime **out_itt);

Converts the time/date property prop_kind to to_zone . When such property does not exist, or does not contain DATE nor DATE-TIME value, then the function returns -1 and no output argument is set.

The vcalendar is used to get the timezone for the property, if provided, otherwise the timezone is tried to be found in the tz_cache . If neither can get it, the iCal builtin timezones are checked. When the set timezone cannot be found, floating time is used (which can be almost always wrong).

Note: this uses i_cal_component_get_first_property(), thus it cannot be used in case any upper caller uses it too at the same time.

Parameters

icomp

an ICalComponent to get the property from

 

prop_kind

an ICalPropertyKind of the property to read

 

to_zone

an ICalTimezone to convert the time to, or NULL for UTC.

[nullable]

vcalendar

an optional VCALENDAR component with timezones for the icomp , or NULL when not available.

[nullable]

tz_cache

an ETimezoneCache to use to read the time zones from, or NULL if not available.

[nullable]

out_itt

return location for the converted time as ICalTime, or NULL when not requested.

[out][optional][transfer full]

Returns

property's time converted into to_zone , or -1, when the conversion was not possible.

Since: 3.58


e_cal_util_property_time_to_zone ()

time_t
e_cal_util_property_time_to_zone (ICalProperty *prop,
                                  ICalTimezone *to_zone,
                                  ICalComponent *vcalendar,
                                  ETimezoneCache *tz_cache,
                                  ICalTime **out_itt);

Converts the time/date property prop to to_zone . When such property does not contain DATE nor DATE-TIME value, the function returns -1 and no output argument is set.

The vcalendar is used to get the timezone for the property, if provided, otherwise the timezone is tried to be found in the tz_cache . If neither can get it, the iCal builtin timezones are checked. When the set timezone cannot be found, floating time is used (which can be almost always wrong).

Parameters

prop

an ICalProperty of DATE or DATE-TIME value

 

to_zone

an ICalTimezone to convert the time to, or NULL for UTC.

[nullable]

vcalendar

an optional VCALENDAR component with timezones for the prop , or NULL when not available.

[nullable]

tz_cache

an ETimezoneCache to use to read the time zones from, or NULL if not available.

[nullable]

out_itt

return location for the converted time as ICalTime, or NULL when not requested.

[out][optional][transfer full]

Returns

property's time converted into to_zone , or -1, when the conversion was not possible.

Since: 3.58


e_cal_util_time_to_zone ()

time_t
e_cal_util_time_to_zone (const ICalTime *itt,
                         const gchar *tzid,
                         ICalTimezone *to_zone,
                         ICalComponent *vcalendar,
                         ETimezoneCache *tz_cache,
                         ICalTime **out_itt);

Converts the itt in tzid to to_zone .

The vcalendar is used to get the timezone for the property, if provided, otherwise the timezone is tried to be found in the tz_cache . If neither can get it, the iCal builtin timezones are checked. When the set timezone cannot be found, floating time is used (which can be almost always wrong).

Parameters

itt

an ICalTime to convert

 

tzid

a timezone ID the itt is at, or NULL for floating time.

[nullable]

vcalendar

an optional VCALENDAR component with timezones for the tzid , or NULL when not available.

[nullable]

tz_cache

an ETimezoneCache to use to read the time zones from, or NULL if not available.

[nullable]

out_itt

return location for the converted time as ICalTime, or NULL when not requested.

[out][optional][transfer full]

Returns

the time converted into to_zone , or -1, when the conversion was not possible.

Since: 3.58