Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Typedefs | Functions
icaltime.h File Reference

struct icaltimetype is a pseudo-object that abstracts time handling. More...

#include <time.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  icaltime_span
 icaltime_span is returned by icalcomponent_get_span() More...
struct  icaltimetype

Defines

#define ICALTIMEZONE_DEFINED

Typedefs

typedef struct _icaltimezone
typedef struct icaltime_span
typedef struct icaltimetype

Functions

struct icaltimetype icaltime_null_time (void)
 Return a null time, which indicates no time has been set.
struct icaltimetype icaltime_null_date (void)
 Return a null date.
struct icaltimetype icaltime_current_time_with_zone (const icaltimezone *zone)
 Returns the current time in the given timezone, as an icaltimetype.
struct icaltimetype icaltime_today (void)
 Returns the current day as an icaltimetype, with is_date set.
struct icaltimetype icaltime_from_timet (const time_t v, const int is_date)
 Convert seconds past UNIX epoch to a timetype.
struct icaltimetype icaltime_from_timet_with_zone (const time_t tm, const int is_date, const icaltimezone *zone)
 Convert seconds past UNIX epoch to a timetype, using timezones.
struct icaltimetype icaltime_from_string (const char *str)
 create a time from an ISO format string
struct icaltimetype icaltime_from_string_with_zone (const char *str, const icaltimezone *zone)
 create a time from an ISO format string
struct icaltimetype icaltime_from_day_of_year (const int doy, const int year)
 Create a new time, given a day of year and a year.
struct icaltimetype icaltime_from_week_number (const int week_number, const int year)
 Contructor (TODO).
time_t icaltime_as_timet (const struct icaltimetype)
 Return the time as seconds past the UNIX epoch.
time_t icaltime_as_timet_with_zone (const struct icaltimetype tt, const icaltimezone *zone)
 Return the time as seconds past the UNIX epoch, using timezones.
const char * icaltime_as_ical_string (const struct icaltimetype tt)
 Return a string represention of the time, in RFC2445 format.
const icaltimezone * icaltime_get_timezone (const struct icaltimetype t)
 Return the timezone.
char * icaltime_get_tzid (const struct icaltimetype t)
 Return the tzid, or NULL for a floating time.
struct icaltimetype icaltime_set_timezone (struct icaltimetype *t, const icaltimezone *zone)
 Set the timezone.
int icaltime_day_of_year (const struct icaltimetype t)
 Return the day of the year of the given time.
int icaltime_day_of_week (const struct icaltimetype t)
 Return the day of the week of the given time.
int icaltime_start_doy_of_week (const struct icaltimetype t)
 Return the day of the year for the Sunday of the week that the given time is within.
int icaltime_start_doy_in_week (const struct icaltimetype t, int fdow)
 Return the day of the year for the first day of the week that the given time is within.
int icaltime_start_doy_week (const struct icaltimetype t, int fdow)
 Return the day of the year for the first day of the week that the given time is within.
int icaltime_week_number (const struct icaltimetype t)
 Return the week number for the week the given time is within.
int icaltime_is_null_time (const struct icaltimetype t)
 Return true of the time is null.
int icaltime_is_valid_time (const struct icaltimetype t)
 Returns false if the time is clearly invalid, but is not null.
int icaltime_is_date (const struct icaltimetype t)
 Returns true if time is of DATE type, false if DATE-TIME.
int icaltime_is_utc (const struct icaltimetype t)
 Returns true if time is relative to UTC zone.
int icaltime_is_floating (const struct icaltimetype t)
 Returns true if time is a floating time.
int icaltime_compare_with_zone (const struct icaltimetype a, const struct icaltimetype b)
 Return -1, 0, or 1 to indicate that a<b, a==b or a>b.
int icaltime_compare (const struct icaltimetype a, const struct icaltimetype b)
 Return -1, 0, or 1 to indicate that a<b, a==b or a>b.
int icaltime_compare_date_only (const struct icaltimetype a, const struct icaltimetype b, icaltimezone *tz)
 like icaltime_compare, but only use the date parts.
void icaltime_adjust (struct icaltimetype *tt, const int days, const int hours, const int minutes, const int seconds)
 Adds or subtracts a number of days, hours, minutes and seconds.
struct icaltimetype icaltime_normalize (const struct icaltimetype t)
 Normalize the icaltime, so that all fields are within the normal range.
struct icaltimetype icaltime_convert_to_zone (const struct icaltimetype tt, icaltimezone *zone)
 convert tt, of timezone tzid, into a utc time.
int icaltime_days_in_month (const int month, const int year)
 Return the number of days in the given month.
struct icaltime_span icaltime_span_new (struct icaltimetype dtstart, struct icaltimetype dtend, int is_busy)
 calculate an icaltimespan given a start and end time.
int icaltime_span_overlaps (icaltime_span *s1, icaltime_span *s2)
 Returns true if the two spans overlap.
int icaltime_span_contains (icaltime_span *s, icaltime_span *container)
 Returns true if the span is totally within the containing span.

Detailed Description

struct icaltimetype is a pseudo-object that abstracts time handling.

It can represent either a DATE or a DATE-TIME (floating, UTC or in a given timezone), and it keeps track internally of its native timezone.

The typical usage is to call the correct constructor specifying the desired timezone. If this is not known until a later time, the correct behavior is to specify a NULL timezone and call icaltime_convert_to_zone() at a later time.

There are several ways to create a new icaltimetype:

italtimetype objects can be converted to different formats:

Accessor methods include:

Query methods include:

Modify, compare and utility methods include:

It can represent either a DATE or a DATE-TIME (floating, UTC or in a given timezone), and it keeps track internally of its native timezone.

The typical usage is to call the correct constructor specifying the desired timezone. If this is not known until a later time, the correct behavior is to specify a NULL timezone and call icaltime_convert_to_zone() at a later time.

There are several ways to create a new icaltimetype:

italtimetype objects can be converted to different formats:

Accessor methods include:

Query methods include:

Modify, compare and utility methods include:

Definition in file icaltime.h.


Class Documentation

struct icaltime_span

icaltime_span is returned by icalcomponent_get_span()

Definition at line 194 of file ical.h.

Collaboration diagram for icaltime_span:
Class Members
time_t end in UTC
int is_busy 1->busy time, 0-> free time
time_t start in UTC
struct icaltimetype

Definition at line 208 of file ical.h.

Collaboration diagram for icaltimetype:
Class Members
int day
int hour
int is_date 1 -> interpret this as date.
int is_daylight 1 -> time is in daylight savings time.
int is_utc 1-> time is in UTC timezone
int minute
int month 1 (Jan) to 12 (Dec).
int second
int year Actual year, e.g.
const icaltimezone * zone timezone

Define Documentation

Definition at line 101 of file icaltime.h.


Typedef Documentation

typedef struct _icaltimezone

Definition at line 102 of file icaltime.h.

typedef struct icaltime_span

Definition at line 112 of file icaltime.h.

typedef struct icaltimetype

Definition at line 138 of file icaltime.h.


Function Documentation

void icaltime_adjust ( struct icaltimetype tt,
const int  days,
const int  hours,
const int  minutes,
const int  seconds 
)

Adds or subtracts a number of days, hours, minutes and seconds.

Adds or subtracts a number of days, hours, minutes and seconds.

Adds (or subtracts) a time from a icaltimetype. NOTE: This function is exactly the same as icaltimezone_adjust_change() except for the type of the first parameter.

Definition at line 781 of file icaltime.c.

                                             {

    int second, minute, hour, day;
    int minutes_overflow, hours_overflow, days_overflow = 0, years_overflow;
    int days_in_month;

    /* If we are passed a date make sure to ignore hour minute and second */
    if (tt->is_date)
       goto IS_DATE;

    /* Add on the seconds. */
    second = tt->second + seconds;
    tt->second = second % 60;
    minutes_overflow = second / 60;
    if (tt->second < 0) {
       tt->second += 60;
       minutes_overflow--;
    }

    /* Add on the minutes. */
    minute = tt->minute + minutes + minutes_overflow;
    tt->minute = minute % 60;
    hours_overflow = minute / 60;
    if (tt->minute < 0) {
       tt->minute += 60;
       hours_overflow--;
    }

    /* Add on the hours. */
    hour = tt->hour + hours + hours_overflow;
    tt->hour = hour % 24;
    days_overflow = hour / 24;
    if (tt->hour < 0) {
       tt->hour += 24;
       days_overflow--;
    }

IS_DATE:
    /* Normalize the month. We do this before handling the day since we may
       need to know what month it is to get the number of days in it.
       Note that months are 1 to 12, so we have to be a bit careful. */
    if (tt->month >= 13) {
       years_overflow = (tt->month - 1) / 12;
       tt->year += years_overflow;
       tt->month -= years_overflow * 12;
    } else if (tt->month <= 0) {
       /* 0 to -11 is -1 year out, -12 to -23 is -2 years. */
       years_overflow = (tt->month / 12) - 1;
       tt->year += years_overflow;
       tt->month -= years_overflow * 12;
    }

    /* Add on the days. */
    day = tt->day + days + days_overflow;
    if (day > 0) {
       for (;;) {
           days_in_month = icaltime_days_in_month (tt->month, tt->year);
           if (day <= days_in_month)
              break;

           tt->month++;
           if (tt->month >= 13) {
              tt->year++;
              tt->month = 1;
           }

           day -= days_in_month;
       }
    } else {
       while (day <= 0) {
           if (tt->month == 1) {
              tt->year--;
              tt->month = 12;
           } else {
              tt->month--;
           }

           day += icaltime_days_in_month (tt->month, tt->year);
       }
    }
    tt->day = day;
}

Here is the call graph for this function:

Return a string represention of the time, in RFC2445 format.

The string is owned by libical

Definition at line 328 of file icaltime.c.

{
    size_t size = 17;
    char* buf = icalmemory_new_buffer(size);

    if(tt.is_date){
       snprintf(buf, size,"%04d%02d%02d",tt.year,tt.month,tt.day);
    } else {
       char* fmt;
       if(tt.is_utc){
           fmt = "%04d%02d%02dT%02d%02d%02dZ";
       } else {
           fmt = "%04d%02d%02dT%02d%02d%02d";
       }
       snprintf(buf, size,fmt,tt.year,tt.month,tt.day,
               tt.hour,tt.minute,tt.second);
    }
    
    icalmemory_add_tmp_buffer(buf);

    return buf;

}

Here is the call graph for this function:

time_t icaltime_as_timet ( const struct icaltimetype  tt)

Return the time as seconds past the UNIX epoch.

While this function is not currently deprecated, it probably won't do what you expect, unless you know what you're doing. In particular, you should only pass an icaltime in UTC, since no conversion is done. Even in that case, it's probably better to just use icaltime_as_timet_with_zone().

Definition at line 247 of file icaltime.c.

{
    struct tm stm;
    time_t t;

    /* If the time is the special null time, return 0. */
    if (icaltime_is_null_time(tt)) {
       return 0;
    }

    /* Copy the icaltimetype to a struct tm. */
    memset (&stm, 0, sizeof (struct tm));

    if (icaltime_is_date(tt)) {
       stm.tm_sec = stm.tm_min = stm.tm_hour = 0;
    } else {
       stm.tm_sec = tt.second;
       stm.tm_min = tt.minute;
       stm.tm_hour = tt.hour;
    }

    stm.tm_mday = tt.day;
    stm.tm_mon = tt.month-1;
    stm.tm_year = tt.year-1900;
    stm.tm_isdst = -1;

    t = make_time(&stm, 0);

    return t;

}

Here is the call graph for this function:

time_t icaltime_as_timet_with_zone ( const struct icaltimetype  _tt,
const icaltimezone *  zone 
)

Return the time as seconds past the UNIX epoch, using timezones.

Return the time as seconds past the UNIX epoch, using timezones.

This convenience method combines a call to icaltime_convert_to_zone() with a call to icaltime_as_timet(). If the input timezone is null, no conversion is done; that is, the time is simply returned as time_t in its native timezone.

Definition at line 287 of file icaltime.c.

{
    struct icaltimetype tt = _tt;
    struct tm stm;
    time_t t;

    /* If the time is the special null time, return 0. */
    if (icaltime_is_null_time(tt)) {
       return 0;
    }

    if (zone != NULL) {
       tt = icaltime_convert_to_zone(_tt, zone);
    }

    /* Copy the icaltimetype to a struct tm. */
    memset (&stm, 0, sizeof (struct tm));

    if (icaltime_is_date(tt)) {
       stm.tm_sec = stm.tm_min = stm.tm_hour = 0;
    } else {
       stm.tm_sec = tt.second;
       stm.tm_min = tt.minute;
       stm.tm_hour = tt.hour;
    }

    stm.tm_mday = tt.day;
    stm.tm_mon = tt.month-1;
    stm.tm_year = tt.year-1900;
    stm.tm_isdst = -1;

    t = make_time(&stm, 0);

    return t;
}

Here is the call graph for this function:

int icaltime_compare ( const struct icaltimetype  a_in,
const struct icaltimetype  b_in 
)

Return -1, 0, or 1 to indicate that a<b, a==b or a>b.

Return -1, 0, or 1 to indicate that a<b, a==b or a>b.

This calls icaltime_compare function after converting them to the utc timezone.

Definition at line 675 of file icaltime.c.

{
    int retval = 0;
    struct icaltimetype a, b;

    a = icaltime_convert_to_zone(a_in, icaltimezone_get_utc_timezone());
    b = icaltime_convert_to_zone(b_in, icaltimezone_get_utc_timezone());

    if (a.year > b.year)
       retval = 1;
    else if (a.year < b.year)
       retval = -1;

    else if (a.month > b.month)
       retval = 1;
    else if (a.month < b.month)
       retval = -1;

    else if (a.day > b.day)
       retval = 1;
    else if (a.day < b.day)
       retval = -1;

    /* if both are dates, we are done */
    if (a.is_date && b.is_date)
       return retval;

    /* else, if we already found a difference, we are done */
    else if (retval != 0)
       return retval;

    /* else, if only one is a date (and we already know the date part is equal),
       then the other is greater */
    else if (b.is_date)
       retval = 1;
    else if (a.is_date)
       retval = -1;

    else if (a.hour > b.hour)
       retval = 1;
    else if (a.hour < b.hour)
       retval = -1;

    else if (a.minute > b.minute)
       retval = 1;
    else if (a.minute < b.minute)
       retval = -1;

    else if (a.second > b.second)
       retval = 1;
    else if (a.second < b.second)
       retval = -1;

    return retval;
}

Here is the call graph for this function:

int icaltime_compare_date_only ( const struct icaltimetype  a,
const struct icaltimetype  b,
icaltimezone *  tz 
)

like icaltime_compare, but only use the date parts.

Definition at line 736 of file icaltime.c.

{
    int retval;
    struct icaltimetype a, b;

    a = icaltime_convert_to_zone(a_in, tz);
    b = icaltime_convert_to_zone(b_in, tz);

    if (a.year > b.year)
       retval = 1;
    else if (a.year < b.year)
       retval = -1;

    else if (a.month > b.month)
       retval = 1;
    else if (a.month < b.month)
       retval = -1;

    else if (a.day > b.day)
       retval = 1;
    else if (a.day < b.day)
       retval = -1;

    else
       retval = 0;

    return retval;
}

Here is the call graph for this function:

Return -1, 0, or 1 to indicate that a<b, a==b or a>b.

struct icaltimetype icaltime_convert_to_zone ( const struct icaltimetype  tt,
icaltimezone *  zone 
) [read]

convert tt, of timezone tzid, into a utc time.

Does nothing if the time is already UTC.

convert tt, of timezone tzid, into a utc time.

Convert a time from its native timezone to a given timezone.

If tt is a date, the returned time is an exact copy of the input. If it's a floating time, the returned object represents the same time translated to the given timezone. Otherwise the time will be converted to the new time zone, and its native timezone set to the right timezone.

Definition at line 875 of file icaltime.c.

                           {

       struct icaltimetype ret = tt;

       /* If it's a date do nothing */
       if (tt.is_date) {
              return ret;
       }

       if (tt.zone == zone) {
              return ret;
       }

       /* If it's a floating time we don't want to adjust the time */
       if (tt.zone != NULL) {
              icaltimezone_convert_time(&ret, tt.zone, zone);
       }

       ret.zone = zone;
       if (zone == icaltimezone_get_utc_timezone()) {
              ret.is_utc = 1;
       } else {
              ret.is_utc = 0;
       }

       return ret;
}

Here is the call graph for this function:

struct icaltimetype icaltime_current_time_with_zone ( const icaltimezone *  zone) [read]

Returns the current time in the given timezone, as an icaltimetype.

Returns the current time in the given timezone, as an icaltimetype.

Returns an icaltimetype representing the current time in the given timezone.

Definition at line 225 of file icaltime.c.

Here is the call graph for this function:

Return the day of the week of the given time.

Sunday is 1

Definition at line 456 of file icaltime.c.

                                                     {
       UTinstant jt;

       memset(&jt,0,sizeof(UTinstant));

       jt.year = t.year;
    jt.month = t.month;
    jt.day = t.day;
    jt.i_hour = 0;
    jt.i_minute = 0;
    jt.i_second = 0;

       juldat(&jt);

       return jt.weekday + 1;
}

Here is the call graph for this function:

Return the day of the year of the given time.

Definition at line 543 of file icaltime.c.

                                                     {
  int is_leap = icaltime_is_leap_year (t.year);

  return days_in_year[is_leap][t.month - 1] + t.day;
}

Here is the call graph for this function:

int icaltime_days_in_month ( const int  month,
const int  year 
)

Return the number of days in the given month.

Definition at line 440 of file icaltime.c.

{

    int days = _days_in_month[month];

    assert(month > 0);
    assert(month <= 12);

    if( month == 2){
       days += icaltime_is_leap_year(year);
    }

    return days;
}

Here is the call graph for this function:

struct icaltimetype icaltime_from_day_of_year ( const int  _doy,
const int  _year 
) [read]

Create a new time, given a day of year and a year.

Definition at line 554 of file icaltime.c.

{
    struct icaltimetype tt = icaltime_null_date();
    int is_leap;
    int month;
    int doy = _doy;
    int year = _year;

    is_leap = icaltime_is_leap_year(year);

    /* Zero and neg numbers represent days  of the previous year */
    if(doy <1){
        year--;
        is_leap = icaltime_is_leap_year(year);
        doy +=  days_in_year[is_leap][12];
    } else if(doy > days_in_year[is_leap][12]){
        /* Move on to the next year*/
        is_leap = icaltime_is_leap_year(year);
        doy -=  days_in_year[is_leap][12];
        year++;
    }

    tt.year = year;

    for (month = 11; month >= 0; month--) {
      if (doy > days_in_year[is_leap][month]) {
       tt.month = month + 1;
       tt.day = doy - days_in_year[is_leap][month];
       break;
      }
    }

    return tt;
}

Here is the call graph for this function:

struct icaltimetype icaltime_from_string ( const char *  str) [read]

create a time from an ISO format string

create a time from an ISO format string

Create a time from an ISO format string.

Todo:
If the given string specifies a DATE-TIME not in UTC, there is no way to know if this is a floating time or really refers to a timezone. We should probably add a new constructor: icaltime_from_string_with_zone()

Definition at line 379 of file icaltime.c.

{
    struct icaltimetype tt = icaltime_null_time();
    int size;

    icalerror_check_arg_re(str!=0,"str",icaltime_null_time());

    size = strlen(str);
    
    if(size == 15) { /* floating time */
       tt.is_utc = 0;
       tt.is_date = 0;
    } else if (size == 16) { /* UTC time, ends in 'Z'*/
       if(str[15] != 'Z')
           goto FAIL;

       tt.is_utc = 1;
       tt.zone = icaltimezone_get_utc_timezone();
       tt.is_date = 0;
    } else if (size == 8) { /* A DATE */
       tt.is_utc = 0;
       tt.is_date = 1;
    } else { /* error */
       goto FAIL;
    }

    if(tt.is_date == 1){
       if (sscanf(str,"%04d%02d%02d",&tt.year,&tt.month,&tt.day) < 3)
           goto FAIL;
    } else {
       char tsep;
       if (sscanf(str,"%04d%02d%02d%c%02d%02d%02d",&tt.year,&tt.month,&tt.day,
              &tsep,&tt.hour,&tt.minute,&tt.second) < 7)
           goto FAIL;

       if(tsep != 'T')
           goto FAIL;
    }

    return tt;    

FAIL:
    icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
    return icaltime_null_time();
}

Here is the call graph for this function:

struct icaltimetype icaltime_from_string_with_zone ( const char *  str,
const icaltimezone *  zone 
) [read]

create a time from an ISO format string

struct icaltimetype icaltime_from_timet ( const time_t  tm,
const int  is_date 
) [read]

Convert seconds past UNIX epoch to a timetype.

Convert seconds past UNIX epoch to a timetype.

Convert seconds past UNIX epoch to a timetype.

Deprecated:
This constructor is deprecated and shouldn't be used in new software. Use icaltime_from_timet_with_zone(time_t, int, icaltimezone *) instead. In the meantime, calls to this method return a floating time, which can always be converted to a local time with an appropriate call to icaltime_convert_to_zone().

Definition at line 144 of file icaltime.c.

{
#ifndef NO_WARN_DEPRECATED
       icalerror_warn("icaltime_from_timet() is DEPRECATED, use icaltime_from_timet_with_zone() instead");
#endif

       return icaltime_from_timet_with_zone(tm, is_date, 0);
}

Here is the call graph for this function:

struct icaltimetype icaltime_from_timet_with_zone ( const time_t  tm,
const int  is_date,
const icaltimezone *  zone 
) [read]

Convert seconds past UNIX epoch to a timetype, using timezones.

Convert seconds past UNIX epoch to a timetype, using timezones.

Parameters:
tmThe time
is_dateBoolean: 1 means we should treat tm as a DATE
zoneThe timezone tm is in, NULL means to treat tm as a floating time

Return a new icaltime instance, initialized to the given time expressed as seconds past UNIX epoch, optionally using the given timezone.

If the caller specifies the is_date param as TRUE, the returned object is of DATE type, otherwise the input is meant to be of DATE-TIME type. If the zone is not specified (NULL zone param) the time is taken to be floating, that is, valid in any timezone. Note that, in addition to the uses specified in [RFC2445], this can be used when doing simple math on couples of times. If the zone is specified (UTC or otherwise), it's stored in the object and it's used as the native timezone for this object. This means that the caller can convert this time to a different target timezone with no need to store the source timezone.

Definition at line 179 of file icaltime.c.

{
    struct icaltimetype tt = icaltime_null_time();
    struct tm t;
    icaltimezone *utc_zone;

    /* Convert the time_t to a struct tm. We can trust gmtime for this. */
#ifdef HAVE_GMTIME_R
    gmtime_r(&tm, &t);
#else
    {
       struct tm *t_ptr = gmtime(&tm);
       t = *t_ptr;
    }
#endif

    tt.year   = t.tm_year + 1900;
    tt.month  = t.tm_mon + 1;
    tt.day    = t.tm_mday;

    if (is_date) { 
       tt.is_date = 1;
       return tt;
    }

    tt.hour   = t.tm_hour;
    tt.minute = t.tm_min;
    tt.second = t.tm_sec;

    /* If it's a floating time, we don't do any conversion. */
    if (zone == NULL) {
       return tt;
    }

    utc_zone = icaltimezone_get_utc_timezone ();
    tt.is_utc = (zone == utc_zone) ? 1 : 0;
    tt.zone = zone;

    return tt;
}

Here is the call graph for this function:

struct icaltimetype icaltime_from_week_number ( const int  week_number,
const int  year 
) [read]

Contructor (TODO).

Create a new time from a weeknumber and a year.

const icaltimezone* icaltime_get_timezone ( const struct icaltimetype  t)

Return the timezone.

Definition at line 905 of file icaltime.c.

                                                   {

       return t.zone;
}
char* icaltime_get_tzid ( const struct icaltimetype  t)

Return the tzid, or NULL for a floating time.

Definition at line 911 of file icaltime.c.

                                               {

       if (t.zone != NULL) {
              return icaltimezone_get_tzid(t.zone);
       } else {
              return NULL;
       }
}

Here is the call graph for this function:

Returns true if time is of DATE type, false if DATE-TIME.

Definition at line 642 of file icaltime.c.

                                                  {

       return t.is_date;
}

Returns true if time is a floating time.

Return true of the time is null.

Definition at line 659 of file icaltime.c.

{
    if (t.second +t.minute+t.hour+t.day+t.month+t.year == 0){
       return 1;
    }

    return 0;

}

Returns true if time is relative to UTC zone.

Todo:
We should only check the zone

Definition at line 651 of file icaltime.c.

                                                 {

       return t.is_utc;
}

Returns false if the time is clearly invalid, but is not null.

This is usually the result of creating a new time type buy not clearing it, or setting one of the flags to an illegal value.

Definition at line 629 of file icaltime.c.

                                                       {
    if(t.is_utc > 1 || t.is_utc < 0 ||
       t.year < 0 || t.year > 3000 ||
       t.is_date > 1 || t.is_date < 0){
       return 0;
    } else {
       return 1;
    }

}
struct icaltimetype icaltime_normalize ( const struct icaltimetype  tt) [read]

Normalize the icaltime, so that all fields are within the normal range.

Normalize the icaltime, so that all fields are within the normal range.

For instance, given a time with minutes=70, the minutes will be reduces to 10, and the hour incremented. This allows the caller to do arithmetic on times without worrying about overflow or underflow.

Implementation note: we call icaltime_adjust() with no adjustment.

Definition at line 361 of file icaltime.c.

{
       struct icaltimetype ret = tt;
       icaltime_adjust(&ret, 0, 0, 0, 0);
       return ret;
}

Here is the call graph for this function:

struct icaltimetype icaltime_null_date ( void  ) [read]

Return a null date.

Definition at line 605 of file icaltime.c.

{
    struct icaltimetype t;
    memset(&t,0,sizeof(struct icaltimetype));

    t.is_date = 1;

    /*
     * Init to -1 to match what icalyacc.y used to do.
     * Does anything depend on this?
     */
    t.hour = -1;
    t.minute = -1;
    t.second = -1;

    return t;
}

Here is the call graph for this function:

struct icaltimetype icaltime_null_time ( void  ) [read]

Return a null time, which indicates no time has been set.

This time represent the beginning of the epoch

Return a null time, which indicates no time has been set.

Return a null time, which is guaranteed not to be equal to any other time.

Definition at line 593 of file icaltime.c.

{
    struct icaltimetype t;
    memset(&t,0,sizeof(struct icaltimetype));

    return t;
}

Here is the call graph for this function:

struct icaltimetype icaltime_set_timezone ( struct icaltimetype t,
const icaltimezone *  zone 
) [read]

Set the timezone.

Force the icaltime to be interpreted relative to another timezone. If you need to do timezone conversion, applying offset adjustments, then you should use icaltime_convert_to_timezone instead.

Definition at line 927 of file icaltime.c.

                                                                        {

       /* If it's a date do nothing */
       if (t->is_date) {
              return *t;
       }

       if (t->zone == zone) {
              return *t;
       }

       t->zone = zone;
       if (zone == icaltimezone_get_utc_timezone()) {
              t->is_utc = 1;
       } else {
              t->is_utc = 0;
       }

       return *t;
}

Here is the call graph for this function:

Returns true if the span is totally within the containing span.

Parameters:
sThe span to test for.
containerThe span to test against.
Returns:
boolean value.

Definition at line 1041 of file icaltime.c.

{

  if ((s->start >= container->start && s->start < container->end) &&
      (s->end   <= container->end   && s->end   > container->start))
    return 1;
  
  return 0;
}
struct icaltime_span icaltime_span_new ( struct icaltimetype  dtstart,
struct icaltimetype  dtend,
int  is_busy 
) [read]

calculate an icaltimespan given a start and end time.

calculate an icaltimespan given a start and end time.

Parameters:
dtstartThe beginning time of the span, can be a date-time or just a date.
dtendThe end time of the span.
is_busyA boolean value, 0/1.
Returns:
A span using the supplied values.

returned span contains times specified in UTC.

Definition at line 961 of file icaltime.c.

{
  icaltime_span span;

  span.is_busy = is_busy;

  span.start   = icaltime_as_timet_with_zone(dtstart,
                                        icaltimezone_get_utc_timezone());

  if (icaltime_is_null_time(dtend)) {
    if (!icaltime_is_date(dtstart)) {
      /* If dtstart is a DATE-TIME and there is no DTEND nor DURATION
        it takes no time */
      span.end = span.start;
      return span;
    } else {
      dtend = dtstart;
    }
  }

  span.end = icaltime_as_timet_with_zone(dtend, icaltimezone_get_utc_timezone());
  
  if (icaltime_is_date(dtstart)) {
    /* no time specified, go until the end of the day..*/
    span.end += 60*60*24 - 1;
  }
  return span;
}

Here is the call graph for this function:

Returns true if the two spans overlap.

Parameters:
s11st span to test
s22nd span to test
Returns:
boolean value

The result is calculated by testing if the start time of s1 is contained by the s2 span, or if the end time of s1 is contained by the s2 span.

Also returns true if the spans are equal.

Note, this will return false if the spans are adjacent.

Definition at line 1007 of file icaltime.c.

{
  /* s1->start in s2 */
  if (s1->start > s2->start && s1->start < s2->end)
    return 1;

  /* s1->end in s2 */
  if (s1->end > s2->start && s1->end < s2->end)
    return 1;

  /* s2->start in s1 */
  if (s2->start > s1->start && s2->start < s1->end)
    return 1;

  /* s2->end in s1 */
  if (s2->end > s1->start && s2->end < s1->end)
    return 1;

  if (s1->start == s2->start && s1->end == s2->end)
    return 1;
  
  return 0;
}

Return the day of the year for the first day of the week that the given time is within.

Return the day of the year for the Sunday of the week that the given time is within.

Return the day of the year for the Sunday of the week that the given time is within.

Deprecated:
Doesn't take into account different week start days.

Definition at line 500 of file icaltime.c.

                                                           {

#ifndef NO_WARN_DEPRECATED
    icalerror_warn("icaltime_start_doy_of_week() is DEPRECATED, use\
       icaltime_start_doy_week() instead");
#endif

    return icaltime_start_doy_week(t, 1);
}

Here is the call graph for this function:

int icaltime_start_doy_week ( const struct icaltimetype  t,
int  fdow 
)

Return the day of the year for the first day of the week that the given time is within.

Definition at line 475 of file icaltime.c.

                                                                  {
       UTinstant jt;
       int delta;

       memset(&jt,0,sizeof(UTinstant));

       jt.year = t.year;
    jt.month = t.month;
    jt.day = t.day;
    jt.i_hour = 0;
    jt.i_minute = 0;
    jt.i_second = 0;

       juldat(&jt);
       caldat(&jt);

       delta = jt.weekday - (fdow - 1);
       if (delta < 0) delta += 7;
       return jt.day_of_year - delta;
}

Here is the call graph for this function:

Here is the caller graph for this function:

struct icaltimetype icaltime_today ( void  ) [read]

Returns the current day as an icaltimetype, with is_date set.

Returns the current day as an icaltimetype, with is_date set.

Returns an icaltimetype representing the current day.

Definition at line 234 of file icaltime.c.

Here is the call graph for this function:

Return the week number for the week the given time is within.

Todo:
Doesn't take into account the start day of the week.

strftime assumes that weeks start on Monday.

Definition at line 514 of file icaltime.c.

{
       UTinstant jt;

       memset(&jt,0,sizeof(UTinstant));

       jt.year = ictt.year;
    jt.month = ictt.month;
    jt.day = ictt.day;
    jt.i_hour = 0;
    jt.i_minute = 0;
    jt.i_second = 0;

       juldat(&jt);
       caldat(&jt);

       return (jt.day_of_year - jt.weekday) / 7;
}

Here is the call graph for this function: