/* Generated file (by generator) */

/*
 * SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org>
 *
 * SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include "i-cal-vcard-time.h"
#include "libical-glib-private.h"

G_DEFINE_TYPE (ICalVcardTime, i_cal_vcard_time, I_CAL_TYPE_OBJECT)

static void i_cal_vcard_time_class_init (G_GNUC_UNUSED ICalVcardTimeClass *klass)
{
}

static void i_cal_vcard_time_init (G_GNUC_UNUSED ICalVcardTime *self)
{
}

/**
 * i_cal_vcard_time_new_full: (skip)
 * @native: The native libical object.
 *
 * Create a new libical-glib object from the native libical object and the owner.
 *
 * Returns: (transfer full): The newly create libical-glib object.
 *
 * Since: 1.0
 **/
ICalVcardTime *
i_cal_vcard_time_new_full (vcardtimetype native)
{
    ICalVcardTime *object;
    vcardtimetype *clone;
    
    
    clone = g_new (vcardtimetype, 1);
    *clone = native;
    object = i_cal_object_construct (I_CAL_VCARD_TYPE_TIME,
                            (gpointer) clone,
                            (GDestroyNotify) g_free,
                            FALSE,
                            NULL);

    return object;
}


/**
 * i_cal_vcard_time_new:
 *
 * Creates a new #ICalVcardTime.
 *
 * Returns: (transfer full): The newly created #ICalVcardTime. It is a null time
 *
 * Since: 4.0
 *
 **/
ICalVcardTime *
i_cal_vcard_time_new (void)
{
    return i_cal_vcard_time_new_full(vcardtime_null_datetime());
}

/**
 * i_cal_vcard_time_clone:
 * @self: The #ICalVcardTime to clone
 *
 * Creates a new #ICalVcardTime, copy of @self.
 *
 * Returns: (transfer full): The newly created #ICalVcardTime, copy of @self.
 *
 * Since: 4.0
 *
 **/
ICalVcardTime *
i_cal_vcard_time_clone (const ICalVcardTime *self)
{
    vcardtimetype *vtt;

    g_return_val_if_fail(I_CAL_VCARD_IS_TIME((ICalVcardTime *)self), NULL);

    vtt = (vcardtimetype *)i_cal_object_get_native ((ICalObject *)self);
    g_return_val_if_fail(vtt != NULL, NULL);

    return i_cal_vcard_time_new_full(*vtt);
}

/**
 * i_cal_vcard_time_new_null_date:
 *
 * Creates a new empty ("null") date.
 *
 * Returns: (transfer full): The newly created #ICalVcardTime
 *
 * Since: 4.0
 *
 **/
ICalVcardTime *
i_cal_vcard_time_new_null_date (void)
{
	return i_cal_vcard_time_new_full (vcardtime_null_date ());
}

/**
 * i_cal_vcard_time_new_null_time:
 *
 * Creates a new empty ("null") time.
 *
 * Returns: (transfer full): The newly created #ICalVcardTime
 *
 * Since: 4.0
 *
 **/
ICalVcardTime *
i_cal_vcard_time_new_null_time (void)
{
	return i_cal_vcard_time_new_full (vcardtime_null_time ());
}

/**
 * i_cal_vcard_time_new_null_timestamp:
 *
 * Creates a new empty ("null") timestamp.
 *
 * Returns: (transfer full): The newly created #ICalVcardTime
 *
 * Since: 4.0
 *
 **/
ICalVcardTime *
i_cal_vcard_time_new_null_timestamp (void)
{
	return i_cal_vcard_time_new_full (vcardtime_null_timestamp ());
}

/**
 * i_cal_vcard_time_new_null_datetime:
 *
 * Creates a new empty ("null") datetime.
 *
 * Returns: (transfer full): The newly created #ICalVcardTime
 *
 * Since: 4.0
 *
 **/
ICalVcardTime *
i_cal_vcard_time_new_null_datetime (void)
{
	return i_cal_vcard_time_new_full (vcardtime_null_datetime ());
}

/**
 * i_cal_vcard_time_new_current_utc_time:
 *
 * Creates a new #ICalVcardTime with the current time in UTC zone.
 *
 * Returns: (transfer full): The newly created #ICalVcardTime
 *
 * Since: 4.0
 *
 **/
ICalVcardTime *
i_cal_vcard_time_new_current_utc_time (void)
{
	return i_cal_vcard_time_new_full (vcardtime_current_utc_time ());
}

/**
 * i_cal_vcard_time_is_null_datetime:
 * @self: The #ICalVcardTime to be checked
 *
 * Returns true if the datetime is null.
 *
 * Returns: Whether @self is null datetime.
 *
 * Since: 4.0
 *
 **/
gboolean
i_cal_vcard_time_is_null_datetime (const ICalVcardTime *self)
{
    g_return_val_if_fail (I_CAL_VCARD_IS_TIME ((ICalVcardTime*)self), FALSE);

	return vcardtime_is_null_datetime (* (vcardtimetype *)i_cal_object_get_native (I_CAL_OBJECT ((ICalObject *)self)));
}

/**
 * i_cal_vcard_time_is_time:
 * @self: The #ICalVcardTime to be checked
 *
 * Returns whether @self represents a time.
 *
 * Returns: Whether @self represents a time.
 *
 * Since: 4.0
 *
 **/
gboolean
i_cal_vcard_time_is_time (const ICalVcardTime *self)
{
    g_return_val_if_fail (I_CAL_VCARD_IS_TIME ((ICalVcardTime*)self), FALSE);

	return vcardtime_is_time (* (vcardtimetype *)i_cal_object_get_native (I_CAL_OBJECT ((ICalObject *)self)));
}

/**
 * i_cal_vcard_time_is_date:
 * @self: The #ICalVcardTime to be checked
 *
 * Returns whether @self represents a date.
 *
 * Returns: Whether @self represents a date.
 *
 * Since: 4.0
 *
 **/
gboolean
i_cal_vcard_time_is_date (const ICalVcardTime *self)
{
    g_return_val_if_fail (I_CAL_VCARD_IS_TIME ((ICalVcardTime*)self), FALSE);

	return vcardtime_is_date (* (vcardtimetype *)i_cal_object_get_native (I_CAL_OBJECT ((ICalObject *)self)));
}

/**
 * i_cal_vcard_time_is_datetime:
 * @self: The #ICalVcardTime to be checked
 *
 * Returns whether @self represents a datetime.
 *
 * Returns: Whether @self represents a datetime.
 *
 * Since: 4.0
 *
 **/
gboolean
i_cal_vcard_time_is_datetime (const ICalVcardTime *self)
{
    g_return_val_if_fail (I_CAL_VCARD_IS_TIME ((ICalVcardTime*)self), FALSE);

	return vcardtime_is_datetime (* (vcardtimetype *)i_cal_object_get_native (I_CAL_OBJECT ((ICalObject *)self)));
}

/**
 * i_cal_vcard_time_is_timestamp:
 * @self: The #ICalVcardTime to be checked
 *
 * Returns whether @self represents a timestamp.
 *
 * Returns: Whether @self represents a timestamp.
 *
 * Since: 4.0
 *
 **/
gboolean
i_cal_vcard_time_is_timestamp (const ICalVcardTime *self)
{
    g_return_val_if_fail (I_CAL_VCARD_IS_TIME ((ICalVcardTime*)self), FALSE);

	return vcardtime_is_timestamp (* (vcardtimetype *)i_cal_object_get_native (I_CAL_OBJECT ((ICalObject *)self)));
}

/**
 * i_cal_vcard_time_is_utc:
 * @self: The #ICalVcardTime to be checked
 *
 * Returns whether @self is in UTC zone.
 *
 * Returns: Whether @self is in UTC zone.
 *
 * Since: 4.0
 *
 **/
gboolean
i_cal_vcard_time_is_utc (const ICalVcardTime *self)
{
    g_return_val_if_fail (I_CAL_VCARD_IS_TIME ((ICalVcardTime*)self), FALSE);

	return vcardtime_is_utc (* (vcardtimetype *)i_cal_object_get_native (I_CAL_OBJECT ((ICalObject *)self)));
}

/**
 * i_cal_vcard_time_is_leap_year:
 * @year: a year
 *
 * Returns whether the @year is a leap year.
 *
 * Returns: Whether the @year is a leap year.
 *
 * Since: 4.0
 *
 **/
gboolean
i_cal_vcard_time_is_leap_year (gint year)
{
	return vcardtime_is_leap_year (year);
}

/**
 * i_cal_vcard_time_is_valid_time:
 * @self: The #ICalVcardTime to be checked
 *
 * Returns whether @self represents a valid time.
 *
 * Returns: Whether @self represents a valid time.
 *
 * Since: 4.0
 *
 **/
gboolean
i_cal_vcard_time_is_valid_time (const ICalVcardTime *self)
{
    g_return_val_if_fail (I_CAL_VCARD_IS_TIME ((ICalVcardTime*)self), FALSE);

	return vcardtime_is_valid_time (* (vcardtimetype *)i_cal_object_get_native (I_CAL_OBJECT ((ICalObject *)self)));
}

/**
 * i_cal_vcard_time_as_vcard_string:
 * @self: The #ICalVcardTime to be converted
 * @flags: bit-or of #ICalVcardTimeConvertFlags
 *
 * Returns a string representation of the @self.
 *
 * Returns: (transfer full): The string representation
 *
 * Since: 4.0
 *
 **/
gchar *
i_cal_vcard_time_as_vcard_string (const ICalVcardTime *self, 
                                  guint flags)
{
    g_return_val_if_fail (I_CAL_VCARD_IS_TIME ((ICalVcardTime*)self), NULL);

	return i_cal_memory_str_to_glib (vcardtime_as_vcard_string_r (* (vcardtimetype *)i_cal_object_get_native (I_CAL_OBJECT ((ICalObject *)self)), flags));
}

/**
 * i_cal_vcard_time_new_from_string:
 * @str: The time string
 * @is_bare_time: Whether the string contains a bare time, not date/time
 *
 * Creates a time from the @str.
 *
 * Returns: (transfer full): The newly created #ICalVcardTime
 *
 * Since: 4.0
 *
 **/
ICalVcardTime *
i_cal_vcard_time_new_from_string (const gchar *str, 
                                  gboolean is_bare_time)
{
    g_return_val_if_fail (str != NULL, NULL);

	return i_cal_vcard_time_new_full (vcardtime_from_string (str, is_bare_time));
}

/**
 * i_cal_vcard_time_get_year:
 * @self: The #ICalVcardTime to be queried
 *
 * Gets the year of #ICalVcardTime.
 *
 * Returns: The year.
 *
 * Since: 4.0
 *
 **/
gint
i_cal_vcard_time_get_year (const ICalVcardTime *self)
{
    g_return_val_if_fail (self != NULL, 0);
    return ((struct vcardtimetype *)i_cal_object_get_native ((ICalObject *)self))->year;
}

/**
 * i_cal_vcard_time_set_year:
 * @self: The #ICalVcardTime to be set
 * @year: The year
 *
 * Sets the year of #ICalVcardTime.
 *
 * Since: 4.0
 *
 **/
void
i_cal_vcard_time_set_year (ICalVcardTime *self, 
                           gint year)
{
    g_return_if_fail (self != NULL);
    ((struct vcardtimetype *)i_cal_object_get_native ((ICalObject *)self))->year = year;
}

/**
 * i_cal_vcard_time_get_month:
 * @self: The #ICalVcardTime to be queried
 *
 * Gets the month of #ICalVcardTime.
 *
 * Returns: The month.
 *
 * Since: 4.0
 *
 **/
gint
i_cal_vcard_time_get_month (const ICalVcardTime *self)
{
    g_return_val_if_fail (self != NULL, 0);
    return ((struct vcardtimetype *)i_cal_object_get_native ((ICalObject *)self))->month;
}

/**
 * i_cal_vcard_time_set_month:
 * @self: The #ICalVcardTime to be set
 * @month: The month
 *
 * Sets the month of #ICalVcardTime.
 *
 * Since: 4.0
 *
 **/
void
i_cal_vcard_time_set_month (ICalVcardTime *self, 
                            gint month)
{
    g_return_if_fail (self != NULL);
    ((struct vcardtimetype *)i_cal_object_get_native ((ICalObject *)self))->month = month;
}

/**
 * i_cal_vcard_time_get_day:
 * @self: The #ICalVcardTime to be queried
 *
 * Gets the day of #ICalVcardTime.
 *
 * Returns: The day.
 *
 * Since: 4.0
 *
 **/
gint
i_cal_vcard_time_get_day (const ICalVcardTime *self)
{
    g_return_val_if_fail (self != NULL, 0);
    return ((struct vcardtimetype *)i_cal_object_get_native ((ICalObject *)self))->day;
}

/**
 * i_cal_vcard_time_set_day:
 * @self: The #ICalVcardTime to be set
 * @day: The day
 *
 * Sets the day of #ICalVcardTime.
 *
 * Since: 4.0
 *
 **/
void
i_cal_vcard_time_set_day (ICalVcardTime *self, 
                          gint day)
{
    g_return_if_fail (self != NULL);
    ((struct vcardtimetype *)i_cal_object_get_native ((ICalObject *)self))->day = day;
}

/**
 * i_cal_vcard_time_get_hour:
 * @self: The #ICalVcardTime to be queried
 *
 * Gets the hour of #ICalVcardTime.
 *
 * Returns: The hour.
 *
 * Since: 4.0
 *
 **/
gint
i_cal_vcard_time_get_hour (const ICalVcardTime *self)
{
    g_return_val_if_fail (self != NULL, 0);
    return ((struct vcardtimetype *)i_cal_object_get_native ((ICalObject *)self))->hour;
}

/**
 * i_cal_vcard_time_set_hour:
 * @self: The #ICalVcardTime to be set
 * @hour: The hour
 *
 * Sets the hour of #ICalVcardTime.
 *
 * Since: 4.0
 *
 **/
void
i_cal_vcard_time_set_hour (ICalVcardTime *self, 
                           gint hour)
{
    g_return_if_fail (self != NULL);
    ((struct vcardtimetype *)i_cal_object_get_native ((ICalObject *)self))->hour = hour;
}

/**
 * i_cal_vcard_time_get_minute:
 * @self: The #ICalVcardTime to be queried
 *
 * Gets the minute of #ICalVcardTime.
 *
 * Returns: The minute.
 *
 * Since: 4.0
 *
 **/
gint
i_cal_vcard_time_get_minute (const ICalVcardTime *self)
{
    g_return_val_if_fail (self != NULL, 0);
    return ((struct vcardtimetype *)i_cal_object_get_native ((ICalObject *)self))->minute;
}

/**
 * i_cal_vcard_time_set_minute:
 * @self: The #ICalVcardTime to be set
 * @minute: The minute
 *
 * Sets the minute of #ICalVcardTime.
 *
 * Since: 4.0
 *
 **/
void
i_cal_vcard_time_set_minute (ICalVcardTime *self, 
                             gint minute)
{
    g_return_if_fail (self != NULL);
    ((struct vcardtimetype *)i_cal_object_get_native ((ICalObject *)self))->minute = minute;
}

/**
 * i_cal_vcard_time_get_second:
 * @self: The #ICalVcardTime to be queried
 *
 * Gets the second of #ICalVcardTime.
 *
 * Returns: The second.
 *
 * Since: 4.0
 *
 **/
gint
i_cal_vcard_time_get_second (const ICalVcardTime *self)
{
    g_return_val_if_fail (self != NULL, 0);
    return ((struct vcardtimetype *)i_cal_object_get_native ((ICalObject *)self))->second;
}

/**
 * i_cal_vcard_time_set_second:
 * @self: The #ICalVcardTime to be set
 * @second: The second
 *
 * Sets the second of #ICalVcardTime.
 *
 * Since: 4.0
 *
 **/
void
i_cal_vcard_time_set_second (ICalVcardTime *self, 
                             gint second)
{
    g_return_if_fail (self != NULL);
    ((struct vcardtimetype *)i_cal_object_get_native ((ICalObject *)self))->second = second;
}

/**
 * i_cal_vcard_time_get_utc_offset:
 * @self: The #ICalVcardTime to be queried
 *
 * Gets the UTC offset of #ICalVcardTime.
 *
 * Returns: The UTC offset
 *
 * Since: 4.0
 *
 **/
gint
i_cal_vcard_time_get_utc_offset (const ICalVcardTime *self)
{
    g_return_val_if_fail (self != NULL, 0);
    return ((struct vcardtimetype *)i_cal_object_get_native ((ICalObject *)self))->utcoffset;
}

/**
 * i_cal_vcard_time_set_utc_offset:
 * @self: The #ICalVcardTime to be set
 * @utc_offset: The UTC offset
 *
 * Sets the UTC offset of #ICalVcardTime.
 *
 * Since: 4.0
 *
 **/
void
i_cal_vcard_time_set_utc_offset (ICalVcardTime *self, 
                                 gint utc_offset)
{
    g_return_if_fail (self != NULL);
    ((struct vcardtimetype *)i_cal_object_get_native ((ICalObject *)self))->utcoffset = utc_offset;
}

/**
 * i_cal_vcard_time_get_date:
 * @self: The #ICalVcardTime to be queried
 * @year: (out caller-allocates) (optional): Out parameter for the 'year' part of the date
 * @month: (out caller-allocates) (optional): Out parameter for the 'month' part of the date
 * @day: (out caller-allocates) (optional): Out parameter for the 'day' part of the date
 *
 * Gets the year/month/date parts of the @timetype in one call.
 *
 * Since: 4.0
 *
 **/
void
i_cal_vcard_time_get_date (const ICalVcardTime *self, 
                           gint *year, 
                           gint *month, 
                           gint *day)
{
    vcardtimetype *itt;
    g_return_if_fail(self != NULL);
    itt = (struct vcardtimetype *)i_cal_object_get_native ((ICalObject *)self);
    g_return_if_fail(itt != NULL);
    if(year) {
        *year = itt->year;
    }
    if(month) {
        *month = itt->month;
    }
    if(day) {
        *day = itt->day;
    }
}

/**
 * i_cal_vcard_time_set_date:
 * @self: The #ICalVcardTime to be set to
 * @year: The 'year' part of the date
 * @month: The 'month' part of the date
 * @day: The 'day' part of the date
 *
 * Sets the year/month/date parts of the @timetype in one call. This doesn't verify validity of the given
 * date.
 *
 * Since: 4.0
 *
 **/
void
i_cal_vcard_time_set_date (ICalVcardTime *self, 
                           gint year, 
                           gint month, 
                           gint day)
{
    vcardtimetype *itt;
    g_return_if_fail(self != NULL);
    itt = (struct vcardtimetype *)i_cal_object_get_native ((ICalObject *)self);
    g_return_if_fail(itt != NULL);
    itt->year = year;
    itt->month = month;
    itt->day = day;
}

/**
 * i_cal_vcard_time_get_time:
 * @self: The #ICalVcardTime to be queried
 * @hour: (out caller-allocates) (optional): Out parameter for the 'hour' part of the time
 * @minute: (out caller-allocates) (optional): Out parameter for the 'minute' part of the time
 * @second: (out caller-allocates) (optional): Out parameter for the 'second' part of the time
 *
 * Gets the hour/minute/second parts of the @timetype in one call.
 *
 * Since: 4.0
 *
 **/
void
i_cal_vcard_time_get_time (const ICalVcardTime *self, 
                           gint *hour, 
                           gint *minute, 
                           gint *second)
{
    vcardtimetype *itt;
    g_return_if_fail(self != NULL);
    itt = (struct vcardtimetype *)i_cal_object_get_native ((ICalObject *)self);
    g_return_if_fail(itt != NULL);
    if(hour) {
        *hour = itt->hour;
    }
    if(minute) {
        *minute = itt->minute;
    }
    if(second) {
        *second = itt->second;
    }
}

/**
 * i_cal_vcard_time_set_time:
 * @self: The #ICalVcardTime to be set to
 * @hour: The 'hour' part of the time
 * @minute: The 'minute' part of the time
 * @second: The 'second' part of the time
 *
 * Sets the hour/minute/second parts of the @timetype in one call. This doesn't verify validity of the given
 * time.
 *
 * Since: 4.0
 *
 **/
void
i_cal_vcard_time_set_time (ICalVcardTime *self, 
                           gint hour, 
                           gint minute, 
                           gint second)
{
    vcardtimetype *itt;
    g_return_if_fail(self != NULL);
    itt = (struct vcardtimetype *)i_cal_object_get_native ((ICalObject *)self);
    g_return_if_fail(itt != NULL);
    itt->hour = hour;
    itt->minute = minute;
    itt->second = second;
}
