<refentry id="glib-Date-and-Time-Functions">
<refmeta>
<refentrytitle role="top_of_page" id="glib-Date-and-Time-Functions.top_of_page">Date and Time Functions</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>GLIB Library</refmiscinfo>
</refmeta>

<refnamediv>
<refname>Date and Time Functions</refname>
<refpurpose>calendrical calculations and miscellaneous time stuff</refpurpose>
</refnamediv>

<refsynopsisdiv id="glib-Date-and-Time-Functions.synopsis" role="synopsis">
<title role="synopsis.title">Synopsis</title>

<synopsis>

#include &lt;glib.h&gt;

#define             <link linkend="G-USEC-PER-SEC--CAPS">G_USEC_PER_SEC</link>
                    <link linkend="GTimeVal">GTimeVal</link>;
<link linkend="void">void</link>                <link linkend="g-get-current-time">g_get_current_time</link>                  (<link linkend="GTimeVal">GTimeVal</link> *result);
<link linkend="void">void</link>                <link linkend="g-usleep">g_usleep</link>                            (<link linkend="gulong">gulong</link> microseconds);
<link linkend="void">void</link>                <link linkend="g-time-val-add">g_time_val_add</link>                      (<link linkend="GTimeVal">GTimeVal</link> *time_,
                                                         <link linkend="glong">glong</link> microseconds);
<link linkend="gboolean">gboolean</link>            <link linkend="g-time-val-from-iso8601">g_time_val_from_iso8601</link>             (const <link linkend="gchar">gchar</link> *iso_date,
                                                         <link linkend="GTimeVal">GTimeVal</link> *time_);
<link linkend="gchar">gchar</link>*              <link linkend="g-time-val-to-iso8601">g_time_val_to_iso8601</link>               (<link linkend="GTimeVal">GTimeVal</link> *time_);

                    <link linkend="GDate">GDate</link>;
typedef             <link linkend="GTime">GTime</link>;
enum                <link linkend="GDateDMY">GDateDMY</link>;
typedef             <link linkend="GDateDay">GDateDay</link>;
enum                <link linkend="GDateMonth">GDateMonth</link>;
typedef             <link linkend="GDateYear">GDateYear</link>;
enum                <link linkend="GDateWeekday">GDateWeekday</link>;

#define             <link linkend="G-DATE-BAD-DAY--CAPS">G_DATE_BAD_DAY</link>
#define             <link linkend="G-DATE-BAD-JULIAN--CAPS">G_DATE_BAD_JULIAN</link>
#define             <link linkend="G-DATE-BAD-YEAR--CAPS">G_DATE_BAD_YEAR</link>

<link linkend="GDate">GDate</link>*              <link linkend="g-date-new">g_date_new</link>                          (void);
<link linkend="GDate">GDate</link>*              <link linkend="g-date-new-dmy">g_date_new_dmy</link>                      (<link linkend="GDateDay">GDateDay</link> day,
                                                         <link linkend="GDateMonth">GDateMonth</link> month,
                                                         <link linkend="GDateYear">GDateYear</link> year);
<link linkend="GDate">GDate</link>*              <link linkend="g-date-new-julian">g_date_new_julian</link>                   (<link linkend="guint32">guint32</link> julian_day);
<link linkend="void">void</link>                <link linkend="g-date-clear">g_date_clear</link>                        (<link linkend="GDate">GDate</link> *date,
                                                         <link linkend="guint">guint</link> n_dates);
<link linkend="void">void</link>                <link linkend="g-date-free">g_date_free</link>                         (<link linkend="GDate">GDate</link> *date);

<link linkend="void">void</link>                <link linkend="g-date-set-day">g_date_set_day</link>                      (<link linkend="GDate">GDate</link> *date,
                                                         <link linkend="GDateDay">GDateDay</link> day);
<link linkend="void">void</link>                <link linkend="g-date-set-month">g_date_set_month</link>                    (<link linkend="GDate">GDate</link> *date,
                                                         <link linkend="GDateMonth">GDateMonth</link> month);
<link linkend="void">void</link>                <link linkend="g-date-set-year">g_date_set_year</link>                     (<link linkend="GDate">GDate</link> *date,
                                                         <link linkend="GDateYear">GDateYear</link> year);
<link linkend="void">void</link>                <link linkend="g-date-set-dmy">g_date_set_dmy</link>                      (<link linkend="GDate">GDate</link> *date,
                                                         <link linkend="GDateDay">GDateDay</link> day,
                                                         <link linkend="GDateMonth">GDateMonth</link> month,
                                                         <link linkend="GDateYear">GDateYear</link> y);
<link linkend="void">void</link>                <link linkend="g-date-set-julian">g_date_set_julian</link>                   (<link linkend="GDate">GDate</link> *date,
                                                         <link linkend="guint32">guint32</link> julian_date);
<link linkend="void">void</link>                <link linkend="g-date-set-time">g_date_set_time</link>                     (<link linkend="GDate">GDate</link> *date,
                                                         <link linkend="GTime">GTime</link> time_);
<link linkend="void">void</link>                <link linkend="g-date-set-time-t">g_date_set_time_t</link>                   (<link linkend="GDate">GDate</link> *date,
                                                         <link linkend="time-t">time_t</link> timet);
<link linkend="void">void</link>                <link linkend="g-date-set-time-val">g_date_set_time_val</link>                 (<link linkend="GDate">GDate</link> *date,
                                                         <link linkend="GTimeVal">GTimeVal</link> *timeval);
<link linkend="void">void</link>                <link linkend="g-date-set-parse">g_date_set_parse</link>                    (<link linkend="GDate">GDate</link> *date,
                                                         const <link linkend="gchar">gchar</link> *str);

<link linkend="void">void</link>                <link linkend="g-date-add-days">g_date_add_days</link>                     (<link linkend="GDate">GDate</link> *date,
                                                         <link linkend="guint">guint</link> n_days);
<link linkend="void">void</link>                <link linkend="g-date-subtract-days">g_date_subtract_days</link>                (<link linkend="GDate">GDate</link> *date,
                                                         <link linkend="guint">guint</link> n_days);
<link linkend="void">void</link>                <link linkend="g-date-add-months">g_date_add_months</link>                   (<link linkend="GDate">GDate</link> *date,
                                                         <link linkend="guint">guint</link> n_months);
<link linkend="void">void</link>                <link linkend="g-date-subtract-months">g_date_subtract_months</link>              (<link linkend="GDate">GDate</link> *date,
                                                         <link linkend="guint">guint</link> n_months);
<link linkend="void">void</link>                <link linkend="g-date-add-years">g_date_add_years</link>                    (<link linkend="GDate">GDate</link> *date,
                                                         <link linkend="guint">guint</link> n_years);
<link linkend="void">void</link>                <link linkend="g-date-subtract-years">g_date_subtract_years</link>               (<link linkend="GDate">GDate</link> *date,
                                                         <link linkend="guint">guint</link> n_years);
<link linkend="gint">gint</link>                <link linkend="g-date-days-between">g_date_days_between</link>                 (const <link linkend="GDate">GDate</link> *date1,
                                                         const <link linkend="GDate">GDate</link> *date2);
<link linkend="gint">gint</link>                <link linkend="g-date-compare">g_date_compare</link>                      (const <link linkend="GDate">GDate</link> *lhs,
                                                         const <link linkend="GDate">GDate</link> *rhs);
<link linkend="void">void</link>                <link linkend="g-date-clamp">g_date_clamp</link>                        (<link linkend="GDate">GDate</link> *date,
                                                         const <link linkend="GDate">GDate</link> *min_date,
                                                         const <link linkend="GDate">GDate</link> *max_date);
<link linkend="void">void</link>                <link linkend="g-date-order">g_date_order</link>                        (<link linkend="GDate">GDate</link> *date1,
                                                         <link linkend="GDate">GDate</link> *date2);

<link linkend="GDateDay">GDateDay</link>            <link linkend="g-date-get-day">g_date_get_day</link>                      (const <link linkend="GDate">GDate</link> *date);
<link linkend="GDateMonth">GDateMonth</link>          <link linkend="g-date-get-month">g_date_get_month</link>                    (const <link linkend="GDate">GDate</link> *date);
<link linkend="GDateYear">GDateYear</link>           <link linkend="g-date-get-year">g_date_get_year</link>                     (const <link linkend="GDate">GDate</link> *date);
<link linkend="guint32">guint32</link>             <link linkend="g-date-get-julian">g_date_get_julian</link>                   (const <link linkend="GDate">GDate</link> *date);
<link linkend="GDateWeekday">GDateWeekday</link>        <link linkend="g-date-get-weekday">g_date_get_weekday</link>                  (const <link linkend="GDate">GDate</link> *date);
<link linkend="guint">guint</link>               <link linkend="g-date-get-day-of-year">g_date_get_day_of_year</link>              (const <link linkend="GDate">GDate</link> *date);

<link linkend="guint8">guint8</link>              <link linkend="g-date-get-days-in-month">g_date_get_days_in_month</link>            (<link linkend="GDateMonth">GDateMonth</link> month,
                                                         <link linkend="GDateYear">GDateYear</link> year);
<link linkend="gboolean">gboolean</link>            <link linkend="g-date-is-first-of-month">g_date_is_first_of_month</link>            (const <link linkend="GDate">GDate</link> *date);
<link linkend="gboolean">gboolean</link>            <link linkend="g-date-is-last-of-month">g_date_is_last_of_month</link>             (const <link linkend="GDate">GDate</link> *date);
<link linkend="gboolean">gboolean</link>            <link linkend="g-date-is-leap-year">g_date_is_leap_year</link>                 (<link linkend="GDateYear">GDateYear</link> year);
<link linkend="guint">guint</link>               <link linkend="g-date-get-monday-week-of-year">g_date_get_monday_week_of_year</link>      (const <link linkend="GDate">GDate</link> *date);
<link linkend="guint8">guint8</link>              <link linkend="g-date-get-monday-weeks-in-year">g_date_get_monday_weeks_in_year</link>     (<link linkend="GDateYear">GDateYear</link> year);
<link linkend="guint">guint</link>               <link linkend="g-date-get-sunday-week-of-year">g_date_get_sunday_week_of_year</link>      (const <link linkend="GDate">GDate</link> *date);
<link linkend="guint8">guint8</link>              <link linkend="g-date-get-sunday-weeks-in-year">g_date_get_sunday_weeks_in_year</link>     (<link linkend="GDateYear">GDateYear</link> year);
<link linkend="guint">guint</link>               <link linkend="g-date-get-iso8601-week-of-year">g_date_get_iso8601_week_of_year</link>     (const <link linkend="GDate">GDate</link> *date);

<link linkend="gsize">gsize</link>               <link linkend="g-date-strftime">g_date_strftime</link>                     (<link linkend="gchar">gchar</link> *s,
                                                         <link linkend="gsize">gsize</link> slen,
                                                         const <link linkend="gchar">gchar</link> *format,
                                                         const <link linkend="GDate">GDate</link> *date);
<link linkend="void">void</link>                <link linkend="g-date-to-struct-tm">g_date_to_struct_tm</link>                 (const <link linkend="GDate">GDate</link> *date,
                                                         <link linkend="struct-tm">struct tm</link> *tm);

<link linkend="gboolean">gboolean</link>            <link linkend="g-date-valid">g_date_valid</link>                        (const <link linkend="GDate">GDate</link> *date);
<link linkend="gboolean">gboolean</link>            <link linkend="g-date-valid-day">g_date_valid_day</link>                    (<link linkend="GDateDay">GDateDay</link> day);
<link linkend="gboolean">gboolean</link>            <link linkend="g-date-valid-month">g_date_valid_month</link>                  (<link linkend="GDateMonth">GDateMonth</link> month);
<link linkend="gboolean">gboolean</link>            <link linkend="g-date-valid-year">g_date_valid_year</link>                   (<link linkend="GDateYear">GDateYear</link> year);
<link linkend="gboolean">gboolean</link>            <link linkend="g-date-valid-dmy">g_date_valid_dmy</link>                    (<link linkend="GDateDay">GDateDay</link> day,
                                                         <link linkend="GDateMonth">GDateMonth</link> month,
                                                         <link linkend="GDateYear">GDateYear</link> year);
<link linkend="gboolean">gboolean</link>            <link linkend="g-date-valid-julian">g_date_valid_julian</link>                 (<link linkend="guint32">guint32</link> julian_date);
<link linkend="gboolean">gboolean</link>            <link linkend="g-date-valid-weekday">g_date_valid_weekday</link>                (<link linkend="GDateWeekday">GDateWeekday</link> weekday);
</synopsis>
</refsynopsisdiv>









<refsect1 id="glib-Date-and-Time-Functions.description" role="desc">
<title role="desc.title">Description</title>
<para>
The <link linkend="GDate"><type>GDate</type></link> data structure represents a day between January 1, Year 1,
and sometime a few thousand years in the future (right now it will go
to the year 65535 or so, but <link linkend="g-date-set-parse"><function>g_date_set_parse()</function></link> only parses up to the
year 8000 or so - just count on "a few thousand"). <link linkend="GDate"><type>GDate</type></link> is meant to
represent everyday dates, not astronomical dates or historical dates
or ISO timestamps or the like. It extrapolates the current Gregorian
calendar forward and backward in time; there is no attempt to change
the calendar to match time periods or locations. <link linkend="GDate"><type>GDate</type></link> does not store
time information; it represents a <emphasis>day</emphasis>.
</para>
<para>
The <link linkend="GDate"><type>GDate</type></link> implementation has several nice features; it is only a
64-bit struct, so storing large numbers of dates is very efficient. It
can keep both a Julian and day-month-year representation of the date,
since some calculations are much easier with one representation or the
other. A Julian representation is simply a count of days since some
fixed day in the past; for <link linkend="GDate"><type>GDate</type></link> the fixed day is January 1, 1 AD.
("Julian" dates in the <link linkend="GDate"><type>GDate</type></link> API aren't really Julian dates in the
technical sense; technically, Julian dates count from the start of the
Julian period, Jan 1, 4713 BC).
</para>
<para>
<link linkend="GDate"><type>GDate</type></link> is simple to use. First you need a "blank" date; you can get a
dynamically allocated date from <link linkend="g-date-new"><function>g_date_new()</function></link>, or you can declare an
automatic variable or array and initialize it to a sane state by
calling <link linkend="g-date-clear"><function>g_date_clear()</function></link>. A cleared date is sane; it's safe to call
<link linkend="g-date-set-dmy"><function>g_date_set_dmy()</function></link> and the other mutator functions to initialize the
value of a cleared date. However, a cleared date is initially
<emphasis>invalid</emphasis>, meaning that it doesn't represent a day
that exists. It is undefined to call any of the date calculation
routines on an invalid date. If you obtain a date from a user or other
unpredictable source, you should check its validity with the
<link linkend="g-date-valid"><function>g_date_valid()</function></link> predicate. <link linkend="g-date-valid"><function>g_date_valid()</function></link> is also used to check for
errors with <link linkend="g-date-set-parse"><function>g_date_set_parse()</function></link> and other functions that can
fail. Dates can be invalidated by calling <link linkend="g-date-clear"><function>g_date_clear()</function></link> again.
</para>
<para>
<emphasis>It is very important to use the API to access the <link linkend="GDate"><type>GDate</type></link>
struct.</emphasis> Often only the day-month-year or only the Julian
representation is valid. Sometimes neither is valid. Use the API.
</para>
<para>
GLib doesn't contain any time-manipulation functions; however, there
is a <link linkend="GTime"><type>GTime</type></link> typedef and a <link linkend="GTimeVal"><type>GTimeVal</type></link> struct which represents a more
precise time (with microseconds). You can request the current time as
a <link linkend="GTimeVal"><type>GTimeVal</type></link> with <link linkend="g-get-current-time"><function>g_get_current_time()</function></link>.
</para>
</refsect1>

<refsect1 id="glib-Date-and-Time-Functions.details" role="details">
<title role="details.title">Details</title>
<refsect2 id="G-USEC-PER-SEC--CAPS" role="macro">
<title>G_USEC_PER_SEC</title>
<indexterm zone="G-USEC-PER-SEC--CAPS"><primary sortas="USEC_PER_SEC">G_USEC_PER_SEC</primary></indexterm><programlisting>#define G_USEC_PER_SEC 1000000
</programlisting>
<para>
Number of microseconds in one second (1 million). This macro is provided for
code readability.
</para></refsect2>
<refsect2 id="GTimeVal" role="struct">
<title>GTimeVal</title>
<indexterm zone="GTimeVal"><primary sortas="TimeVal">GTimeVal</primary></indexterm><programlisting>typedef struct {
  glong tv_sec;
  glong tv_usec;
} GTimeVal;
</programlisting>
<para>
Represents a precise time, with seconds and microseconds.
Similar to the <structname>struct timeval</structname> returned by
the <function><link linkend="gettimeofday"><function>gettimeofday()</function></link></function> UNIX call.
</para><variablelist role="struct">
<varlistentry>
<term><link linkend="glong">glong</link>&#160;<structfield>tv_sec</structfield>;</term>
<listitem><simpara>seconds
</simpara></listitem>
</varlistentry>
<varlistentry>
<term><link linkend="glong">glong</link>&#160;<structfield>tv_usec</structfield>;</term>
<listitem><simpara>microseconds
</simpara></listitem>
</varlistentry>
</variablelist></refsect2>
<refsect2 id="g-get-current-time" role="function">
<title>g_get_current_time ()</title>
<indexterm zone="g-get-current-time"><primary sortas="get_current_time">g_get_current_time</primary></indexterm><programlisting><link linkend="void">void</link>                g_get_current_time                  (<link linkend="GTimeVal">GTimeVal</link> *result);</programlisting>
<para>
Equivalent to the UNIX <link linkend="gettimeofday"><function>gettimeofday()</function></link> function, but portable.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>result</parameter>&#160;:</term>
<listitem><simpara> <link linkend="GTimeVal"><type>GTimeVal</type></link> structure in which to store current time.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-usleep" role="function">
<title>g_usleep ()</title>
<indexterm zone="g-usleep"><primary sortas="usleep">g_usleep</primary></indexterm><programlisting><link linkend="void">void</link>                g_usleep                            (<link linkend="gulong">gulong</link> microseconds);</programlisting>
<para>
Pauses the current thread for the given number of microseconds. There
are 1 million microseconds per second (represented by the
<link linkend="G-USEC-PER-SEC--CAPS"><type>G_USEC_PER_SEC</type></link> macro). <link linkend="g-usleep"><function>g_usleep()</function></link> may have limited precision,
depending on hardware and operating system; don't rely on the exact
length of the sleep.
</para><variablelist role="params">
<varlistentry><term><parameter>microseconds</parameter>&#160;:</term>
<listitem><simpara>number of microseconds to pause
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-time-val-add" role="function">
<title>g_time_val_add ()</title>
<indexterm zone="g-time-val-add"><primary sortas="time_val_add">g_time_val_add</primary></indexterm><programlisting><link linkend="void">void</link>                g_time_val_add                      (<link linkend="GTimeVal">GTimeVal</link> *time_,
                                                         <link linkend="glong">glong</link> microseconds);</programlisting>
<para>
Adds the given number of microseconds to <parameter>time_</parameter>. <parameter>microseconds</parameter> can
also be negative to decrease the value of <parameter>time_</parameter>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>time_</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GTimeVal"><type>GTimeVal</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>microseconds</parameter>&#160;:</term>
<listitem><simpara> number of microseconds to add to <parameter>time</parameter>
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-time-val-from-iso8601" role="function" condition="since:2.12">
<title>g_time_val_from_iso8601 ()</title>
<indexterm zone="g-time-val-from-iso8601" role="2.12"><primary sortas="time_val_from_iso8601">g_time_val_from_iso8601</primary></indexterm><programlisting><link linkend="gboolean">gboolean</link>            g_time_val_from_iso8601             (const <link linkend="gchar">gchar</link> *iso_date,
                                                         <link linkend="GTimeVal">GTimeVal</link> *time_);</programlisting>
<para>
Converts a string containing an ISO 8601 encoded date and time
to a <link linkend="GTimeVal"><type>GTimeVal</type></link> and puts it into <parameter>time_</parameter>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>iso_date</parameter>&#160;:</term>
<listitem><simpara> an ISO 8601 encoded date string
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>time_</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GTimeVal"><type>GTimeVal</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> <link linkend="TRUE--CAPS"><literal>TRUE</literal></link> if the conversion was successful.

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.12</para></refsect2>
<refsect2 id="g-time-val-to-iso8601" role="function" condition="since:2.12">
<title>g_time_val_to_iso8601 ()</title>
<indexterm zone="g-time-val-to-iso8601" role="2.12"><primary sortas="time_val_to_iso8601">g_time_val_to_iso8601</primary></indexterm><programlisting><link linkend="gchar">gchar</link>*              g_time_val_to_iso8601               (<link linkend="GTimeVal">GTimeVal</link> *time_);</programlisting>
<para>
Converts <parameter>time_</parameter> into an ISO 8601 encoded string, relative to the
Coordinated Universal Time (UTC).</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>time_</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GTimeVal"><type>GTimeVal</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> a newly allocated string containing an ISO 8601 date

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.12</para></refsect2>
<refsect2 id="GDate" role="struct">
<title>GDate</title>
<indexterm zone="GDate"><primary sortas="Date">GDate</primary></indexterm><programlisting>typedef struct {
  guint julian_days : 32; /* julian days representation - we use a
                           *  bitfield hoping that 64 bit platforms
                           *  will pack this whole struct in one big
                           *  int
                           */

  guint julian : 1;    /* julian is valid */
  guint dmy    : 1;    /* dmy is valid */

  /* DMY representation */
  guint day    : 6;
  guint month  : 4;
  guint year   : 16;
} GDate;
</programlisting>
<para>
Represents a day between January 1, Year 1 and a few thousand years in
the future. None of its members should be accessed directly. If the
<structname>GDate</structname> is obtained from <link linkend="g-date-new"><function>g_date_new()</function></link>, it will
be safe to mutate but invalid and thus not safe for calendrical computations.
If it's declared on the stack, it will contain garbage so must be
initialized with <link linkend="g-date-clear"><function>g_date_clear()</function></link>. <link linkend="g-date-clear"><function>g_date_clear()</function></link> makes the date invalid
but sane. An invalid date doesn't represent a day, it's "empty." A
date becomes valid after you set it to a Julian day or you set a day,
month, and year.
</para><variablelist role="struct">
<varlistentry>
<term><link linkend="guint">guint</link>&#160;<structfield>julian_days</structfield>&#160;:&#160;32;</term>
<listitem><simpara>the Julian representation of the date
</simpara></listitem>
</varlistentry>
<varlistentry>
<term><link linkend="guint">guint</link>&#160;<structfield>julian</structfield>&#160;:&#160;1;</term>
<listitem><simpara>this bit is set if <parameter>julian_days</parameter> is valid
</simpara></listitem>
</varlistentry>
<varlistentry>
<term><link linkend="guint">guint</link>&#160;<structfield>dmy</structfield>&#160;:&#160;1;</term>
<listitem><simpara>this is set if <parameter>day</parameter>, <parameter>month</parameter> and <parameter>year</parameter> are valid
</simpara></listitem>
</varlistentry>
<varlistentry>
<term><link linkend="guint">guint</link>&#160;<structfield>day</structfield>&#160;:&#160;6;</term>
<listitem><simpara>the day of the day-month-year representation of the date, as 
  a number between 1 and 31
</simpara></listitem>
</varlistentry>
<varlistentry>
<term><link linkend="guint">guint</link>&#160;<structfield>month</structfield>&#160;:&#160;4;</term>
<listitem><simpara>the day of the day-month-year representation of the date, as 
  a number between 1 and 12
</simpara></listitem>
</varlistentry>
<varlistentry>
<term><link linkend="guint">guint</link>&#160;<structfield>year</structfield>&#160;:&#160;16;</term>
<listitem><simpara>the day of the day-month-year representation of the date
</simpara></listitem>
</varlistentry>
</variablelist></refsect2>
<refsect2 id="GTime" role="typedef">
<title>GTime</title>
<indexterm zone="GTime"><primary sortas="Time">GTime</primary></indexterm><programlisting>typedef gint32  GTime;
</programlisting>
<para>
Simply a replacement for <type>time_t</type>. It has been deprected
since it is <emphasis>not</emphasis> equivalent to <type>time_t</type>
on 64-bit platforms with a 64-bit <type>time_t</type>.
Unrelated to <link linkend="GTimer"><type>GTimer</type></link>.
</para>
<para>
Note that <type>GTime</type> is defined to always be a 32bit integer,
unlike <type>time_t</type> which may be 64bit on some systems.
Therefore, <type>GTime</type> will overflow in the year 2038, and
you cannot use the address of a <type>GTime</type> variable as argument
to the UNIX <link linkend="time"><function>time()</function></link> function. Instead, do the following:
<informalexample>
<programlisting>
time_t ttime;
GTime gtime;
time (&amp;ttime);
gtime = (GTime)ttime;
</programlisting>
</informalexample>
</para></refsect2>
<refsect2 id="GDateDMY" role="enum">
<title>enum GDateDMY</title>
<indexterm zone="GDateDMY"><primary sortas="DateDMY">GDateDMY</primary></indexterm><programlisting>typedef enum
{
  G_DATE_DAY   = 0,
  G_DATE_MONTH = 1,
  G_DATE_YEAR  = 2
} GDateDMY;
</programlisting>
<para>
This enumeration isn't used in the API, but may be useful if you need
to mark a number as a day, month, or year.
</para><variablelist role="enum">
<varlistentry id="G-DATE-DAY--CAPS" role="constant">
<term><literal>G_DATE_DAY</literal></term>
<listitem><simpara>a day
</simpara></listitem>
</varlistentry>
<varlistentry id="G-DATE-MONTH--CAPS" role="constant">
<term><literal>G_DATE_MONTH</literal></term>
<listitem><simpara>a month
</simpara></listitem>
</varlistentry>
<varlistentry id="G-DATE-YEAR--CAPS" role="constant">
<term><literal>G_DATE_YEAR</literal></term>
<listitem><simpara>a year
</simpara></listitem>
</varlistentry>
</variablelist></refsect2>
<refsect2 id="GDateDay" role="typedef">
<title>GDateDay</title>
<indexterm zone="GDateDay"><primary sortas="DateDay">GDateDay</primary></indexterm><programlisting>typedef guint8  GDateDay;   /* day of the month */
</programlisting>
<para>
Integer representing a day of the month; between 1 and
31. <link linkend="G-DATE-BAD-DAY--CAPS"><type>G_DATE_BAD_DAY</type></link> represents an invalid day of the month.
</para></refsect2>
<refsect2 id="GDateMonth" role="enum">
<title>enum GDateMonth</title>
<indexterm zone="GDateMonth"><primary sortas="DateMonth">GDateMonth</primary></indexterm><programlisting>typedef enum
{
  G_DATE_BAD_MONTH = 0,
  G_DATE_JANUARY   = 1,
  G_DATE_FEBRUARY  = 2,
  G_DATE_MARCH     = 3,
  G_DATE_APRIL     = 4,
  G_DATE_MAY       = 5,
  G_DATE_JUNE      = 6,
  G_DATE_JULY      = 7,
  G_DATE_AUGUST    = 8,
  G_DATE_SEPTEMBER = 9,
  G_DATE_OCTOBER   = 10,
  G_DATE_NOVEMBER  = 11,
  G_DATE_DECEMBER  = 12
} GDateMonth;
</programlisting>
<para>
Enumeration representing a month; values are <link linkend="G-DATE-JANUARY--CAPS"><type>G_DATE_JANUARY</type></link>,
<link linkend="G-DATE-FEBRUARY--CAPS"><type>G_DATE_FEBRUARY</type></link>, etc. <link linkend="G-DATE-BAD-MONTH--CAPS"><type>G_DATE_BAD_MONTH</type></link> is the invalid value.
</para><variablelist role="enum">
<varlistentry id="G-DATE-BAD-MONTH--CAPS" role="constant">
<term><literal>G_DATE_BAD_MONTH</literal></term>
<listitem><simpara>invalid value
</simpara></listitem>
</varlistentry>
<varlistentry id="G-DATE-JANUARY--CAPS" role="constant">
<term><literal>G_DATE_JANUARY</literal></term>
<listitem><simpara>January
</simpara></listitem>
</varlistentry>
<varlistentry id="G-DATE-FEBRUARY--CAPS" role="constant">
<term><literal>G_DATE_FEBRUARY</literal></term>
<listitem><simpara>February
</simpara></listitem>
</varlistentry>
<varlistentry id="G-DATE-MARCH--CAPS" role="constant">
<term><literal>G_DATE_MARCH</literal></term>
<listitem><simpara>March
</simpara></listitem>
</varlistentry>
<varlistentry id="G-DATE-APRIL--CAPS" role="constant">
<term><literal>G_DATE_APRIL</literal></term>
<listitem><simpara>April
</simpara></listitem>
</varlistentry>
<varlistentry id="G-DATE-MAY--CAPS" role="constant">
<term><literal>G_DATE_MAY</literal></term>
<listitem><simpara>May
</simpara></listitem>
</varlistentry>
<varlistentry id="G-DATE-JUNE--CAPS" role="constant">
<term><literal>G_DATE_JUNE</literal></term>
<listitem><simpara>June
</simpara></listitem>
</varlistentry>
<varlistentry id="G-DATE-JULY--CAPS" role="constant">
<term><literal>G_DATE_JULY</literal></term>
<listitem><simpara>July
</simpara></listitem>
</varlistentry>
<varlistentry id="G-DATE-AUGUST--CAPS" role="constant">
<term><literal>G_DATE_AUGUST</literal></term>
<listitem><simpara>August
</simpara></listitem>
</varlistentry>
<varlistentry id="G-DATE-SEPTEMBER--CAPS" role="constant">
<term><literal>G_DATE_SEPTEMBER</literal></term>
<listitem><simpara>September
</simpara></listitem>
</varlistentry>
<varlistentry id="G-DATE-OCTOBER--CAPS" role="constant">
<term><literal>G_DATE_OCTOBER</literal></term>
<listitem><simpara>October
</simpara></listitem>
</varlistentry>
<varlistentry id="G-DATE-NOVEMBER--CAPS" role="constant">
<term><literal>G_DATE_NOVEMBER</literal></term>
<listitem><simpara>November
</simpara></listitem>
</varlistentry>
<varlistentry id="G-DATE-DECEMBER--CAPS" role="constant">
<term><literal>G_DATE_DECEMBER</literal></term>
<listitem><simpara>December
</simpara></listitem>
</varlistentry>
</variablelist></refsect2>
<refsect2 id="GDateYear" role="typedef">
<title>GDateYear</title>
<indexterm zone="GDateYear"><primary sortas="DateYear">GDateYear</primary></indexterm><programlisting>typedef guint16 GDateYear;
</programlisting>
<para>
Integer representing a year; <link linkend="G-DATE-BAD-YEAR--CAPS"><type>G_DATE_BAD_YEAR</type></link> is the invalid
value. The year must be 1 or higher; negative (BC) years are not
allowed. The year is represented with four digits.
</para></refsect2>
<refsect2 id="GDateWeekday" role="enum">
<title>enum GDateWeekday</title>
<indexterm zone="GDateWeekday"><primary sortas="DateWeekday">GDateWeekday</primary></indexterm><programlisting>typedef enum
{
  G_DATE_BAD_WEEKDAY  = 0,
  G_DATE_MONDAY       = 1,
  G_DATE_TUESDAY      = 2,
  G_DATE_WEDNESDAY    = 3,
  G_DATE_THURSDAY     = 4,
  G_DATE_FRIDAY       = 5,
  G_DATE_SATURDAY     = 6,
  G_DATE_SUNDAY       = 7
} GDateWeekday;
</programlisting>
<para>
Enumeration representing a day of the week; <link linkend="G-DATE-MONDAY--CAPS"><type>G_DATE_MONDAY</type></link>,
<link linkend="G-DATE-TUESDAY--CAPS"><type>G_DATE_TUESDAY</type></link>, etc. <link linkend="G-DATE-BAD-WEEKDAY--CAPS"><type>G_DATE_BAD_WEEKDAY</type></link> is an invalid weekday.
</para><variablelist role="enum">
<varlistentry id="G-DATE-BAD-WEEKDAY--CAPS" role="constant">
<term><literal>G_DATE_BAD_WEEKDAY</literal></term>
<listitem><simpara>invalid value
</simpara></listitem>
</varlistentry>
<varlistentry id="G-DATE-MONDAY--CAPS" role="constant">
<term><literal>G_DATE_MONDAY</literal></term>
<listitem><simpara>Monday
</simpara></listitem>
</varlistentry>
<varlistentry id="G-DATE-TUESDAY--CAPS" role="constant">
<term><literal>G_DATE_TUESDAY</literal></term>
<listitem><simpara>Tuesday
</simpara></listitem>
</varlistentry>
<varlistentry id="G-DATE-WEDNESDAY--CAPS" role="constant">
<term><literal>G_DATE_WEDNESDAY</literal></term>
<listitem><simpara>Wednesday
</simpara></listitem>
</varlistentry>
<varlistentry id="G-DATE-THURSDAY--CAPS" role="constant">
<term><literal>G_DATE_THURSDAY</literal></term>
<listitem><simpara>Thursday
</simpara></listitem>
</varlistentry>
<varlistentry id="G-DATE-FRIDAY--CAPS" role="constant">
<term><literal>G_DATE_FRIDAY</literal></term>
<listitem><simpara>Friday
</simpara></listitem>
</varlistentry>
<varlistentry id="G-DATE-SATURDAY--CAPS" role="constant">
<term><literal>G_DATE_SATURDAY</literal></term>
<listitem><simpara>Saturday
</simpara></listitem>
</varlistentry>
<varlistentry id="G-DATE-SUNDAY--CAPS" role="constant">
<term><literal>G_DATE_SUNDAY</literal></term>
<listitem><simpara>Sunday
</simpara></listitem>
</varlistentry>
</variablelist></refsect2>
<refsect2 id="G-DATE-BAD-DAY--CAPS" role="macro">
<title>G_DATE_BAD_DAY</title>
<indexterm zone="G-DATE-BAD-DAY--CAPS"><primary sortas="DATE_BAD_DAY">G_DATE_BAD_DAY</primary></indexterm><programlisting>#define G_DATE_BAD_DAY    0U
</programlisting>
<para>
Represents an invalid <link linkend="GDateDay"><type>GDateDay</type></link>.
</para></refsect2>
<refsect2 id="G-DATE-BAD-JULIAN--CAPS" role="macro">
<title>G_DATE_BAD_JULIAN</title>
<indexterm zone="G-DATE-BAD-JULIAN--CAPS"><primary sortas="DATE_BAD_JULIAN">G_DATE_BAD_JULIAN</primary></indexterm><programlisting>#define G_DATE_BAD_JULIAN 0U
</programlisting>
<para>
Represents an invalid Julian day number.
</para></refsect2>
<refsect2 id="G-DATE-BAD-YEAR--CAPS" role="macro">
<title>G_DATE_BAD_YEAR</title>
<indexterm zone="G-DATE-BAD-YEAR--CAPS"><primary sortas="DATE_BAD_YEAR">G_DATE_BAD_YEAR</primary></indexterm><programlisting>#define G_DATE_BAD_YEAR   0U
</programlisting>
<para>
Represents an invalid year.
</para></refsect2>
<refsect2 id="g-date-new" role="function">
<title>g_date_new ()</title>
<indexterm zone="g-date-new"><primary sortas="date_new">g_date_new</primary></indexterm><programlisting><link linkend="GDate">GDate</link>*              g_date_new                          (void);</programlisting>
<para>
Allocates a <link linkend="GDate"><type>GDate</type></link> and initializes it to a sane state. The new date will
be cleared (as if you'd called <link linkend="g-date-clear"><function>g_date_clear()</function></link>) but invalid (it won't
represent an existing day). Free the return value with <link linkend="g-date-free"><function>g_date_free()</function></link>.
</para><variablelist role="params">
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara>a newly-allocated <link linkend="GDate"><type>GDate</type></link>
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-date-new-dmy" role="function">
<title>g_date_new_dmy ()</title>
<indexterm zone="g-date-new-dmy"><primary sortas="date_new_dmy">g_date_new_dmy</primary></indexterm><programlisting><link linkend="GDate">GDate</link>*              g_date_new_dmy                      (<link linkend="GDateDay">GDateDay</link> day,
                                                         <link linkend="GDateMonth">GDateMonth</link> month,
                                                         <link linkend="GDateYear">GDateYear</link> year);</programlisting>
<para>
Like <link linkend="g-date-new"><function>g_date_new()</function></link>, but also sets the value of the date. Assuming the
day-month-year triplet you pass in represents an existing day, the
returned date will be valid.
</para><variablelist role="params">
<varlistentry><term><parameter>day</parameter>&#160;:</term>
<listitem><simpara>day of the month
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>month</parameter>&#160;:</term>
<listitem><simpara>month of the year
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>year</parameter>&#160;:</term>
<listitem><simpara>year
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara>a newly-allocated <link linkend="GDate"><type>GDate</type></link> initialized with <parameter>day</parameter>, <parameter>month</parameter>, and <parameter>year</parameter>
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-date-new-julian" role="function">
<title>g_date_new_julian ()</title>
<indexterm zone="g-date-new-julian"><primary sortas="date_new_julian">g_date_new_julian</primary></indexterm><programlisting><link linkend="GDate">GDate</link>*              g_date_new_julian                   (<link linkend="guint32">guint32</link> julian_day);</programlisting>
<para>
Like <link linkend="g-date-new"><function>g_date_new()</function></link>, but also sets the value of the date. Assuming the
Julian day number you pass in is valid (greater than 0, less than an
unreasonably large number), the returned date will be valid.
</para><variablelist role="params">
<varlistentry><term><parameter>julian_day</parameter>&#160;:</term>
<listitem><simpara>days since January 1, Year 1
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara>a newly-allocated <link linkend="GDate"><type>GDate</type></link> initialized with <parameter>julian_day</parameter>
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-date-clear" role="function">
<title>g_date_clear ()</title>
<indexterm zone="g-date-clear"><primary sortas="date_clear">g_date_clear</primary></indexterm><programlisting><link linkend="void">void</link>                g_date_clear                        (<link linkend="GDate">GDate</link> *date,
                                                         <link linkend="guint">guint</link> n_dates);</programlisting>
<para>
Initializes one or more <link linkend="GDate"><type>GDate</type></link> structs to a sane but invalid
state. The cleared dates will not represent an existing date, but will
not contain garbage. Useful to init a date declared on the stack.
Validity can be tested with <link linkend="g-date-valid"><function>g_date_valid()</function></link>.
</para><variablelist role="params">
<varlistentry><term><parameter>date</parameter>&#160;:</term>
<listitem><simpara>pointer to one or more dates to clear
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>n_dates</parameter>&#160;:</term>
<listitem><simpara>number of dates to clear
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-date-free" role="function">
<title>g_date_free ()</title>
<indexterm zone="g-date-free"><primary sortas="date_free">g_date_free</primary></indexterm><programlisting><link linkend="void">void</link>                g_date_free                         (<link linkend="GDate">GDate</link> *date);</programlisting>
<para>
Frees a <link linkend="GDate"><type>GDate</type></link> returned from <link linkend="g-date-new"><function>g_date_new()</function></link>.
</para><variablelist role="params">
<varlistentry><term><parameter>date</parameter>&#160;:</term>
<listitem><simpara>a <link linkend="GDate"><type>GDate</type></link>
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-date-set-day" role="function">
<title>g_date_set_day ()</title>
<indexterm zone="g-date-set-day"><primary sortas="date_set_day">g_date_set_day</primary></indexterm><programlisting><link linkend="void">void</link>                g_date_set_day                      (<link linkend="GDate">GDate</link> *date,
                                                         <link linkend="GDateDay">GDateDay</link> day);</programlisting>
<para>
Sets the day of the month for a <link linkend="GDate"><type>GDate</type></link>. If the resulting day-month-year
triplet is invalid, the date will be invalid.
</para><variablelist role="params">
<varlistentry><term><parameter>date</parameter>&#160;:</term>
<listitem><simpara>a <link linkend="GDate"><type>GDate</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>day</parameter>&#160;:</term>
<listitem><simpara>day to set
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-date-set-month" role="function">
<title>g_date_set_month ()</title>
<indexterm zone="g-date-set-month"><primary sortas="date_set_month">g_date_set_month</primary></indexterm><programlisting><link linkend="void">void</link>                g_date_set_month                    (<link linkend="GDate">GDate</link> *date,
                                                         <link linkend="GDateMonth">GDateMonth</link> month);</programlisting>
<para>
Sets the month of the year for a <link linkend="GDate"><type>GDate</type></link>.  If the resulting
day-month-year triplet is invalid, the date will be invalid.
</para><variablelist role="params">
<varlistentry><term><parameter>date</parameter>&#160;:</term>
<listitem><simpara>a <link linkend="GDate"><type>GDate</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>month</parameter>&#160;:</term>
<listitem><simpara>month to set
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-date-set-year" role="function">
<title>g_date_set_year ()</title>
<indexterm zone="g-date-set-year"><primary sortas="date_set_year">g_date_set_year</primary></indexterm><programlisting><link linkend="void">void</link>                g_date_set_year                     (<link linkend="GDate">GDate</link> *date,
                                                         <link linkend="GDateYear">GDateYear</link> year);</programlisting>
<para>
Sets the year for a <link linkend="GDate"><type>GDate</type></link>. If the resulting day-month-year triplet is
invalid, the date will be invalid.
</para><variablelist role="params">
<varlistentry><term><parameter>date</parameter>&#160;:</term>
<listitem><simpara>a <link linkend="GDate"><type>GDate</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>year</parameter>&#160;:</term>
<listitem><simpara>year to set
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-date-set-dmy" role="function">
<title>g_date_set_dmy ()</title>
<indexterm zone="g-date-set-dmy"><primary sortas="date_set_dmy">g_date_set_dmy</primary></indexterm><programlisting><link linkend="void">void</link>                g_date_set_dmy                      (<link linkend="GDate">GDate</link> *date,
                                                         <link linkend="GDateDay">GDateDay</link> day,
                                                         <link linkend="GDateMonth">GDateMonth</link> month,
                                                         <link linkend="GDateYear">GDateYear</link> y);</programlisting>
<para>
Sets the value of a <link linkend="GDate"><type>GDate</type></link> from a day, month, and year. The day-month-year
triplet must be valid; if you aren't sure it is, call <link linkend="g-date-valid-dmy"><function>g_date_valid_dmy()</function></link> to
check before you set it.
</para><variablelist role="params">
<varlistentry><term><parameter>date</parameter>&#160;:</term>
<listitem><simpara>a <link linkend="GDate"><type>GDate</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>day</parameter>&#160;:</term>
<listitem><simpara>day
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>month</parameter>&#160;:</term>
<listitem><simpara>month
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>y</parameter>&#160;:</term>
<listitem><simpara>year
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-date-set-julian" role="function">
<title>g_date_set_julian ()</title>
<indexterm zone="g-date-set-julian"><primary sortas="date_set_julian">g_date_set_julian</primary></indexterm><programlisting><link linkend="void">void</link>                g_date_set_julian                   (<link linkend="GDate">GDate</link> *date,
                                                         <link linkend="guint32">guint32</link> julian_date);</programlisting>
<para>
Sets the value of a <link linkend="GDate"><type>GDate</type></link> from a Julian day number.
</para><variablelist role="params">
<varlistentry><term><parameter>date</parameter>&#160;:</term>
<listitem><simpara>a <link linkend="GDate"><type>GDate</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>julian_date</parameter>&#160;:</term>
<listitem><simpara>Julian day number (days since January 1, Year 1)
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-date-set-time" role="function" condition="deprecated:">
<title>g_date_set_time ()</title>
<indexterm zone="g-date-set-time" role="deprecated"><primary sortas="date_set_time">g_date_set_time</primary></indexterm><programlisting><link linkend="void">void</link>                g_date_set_time                     (<link linkend="GDate">GDate</link> *date,
                                                         <link linkend="GTime">GTime</link> time_);</programlisting>
<warning><para><literal>g_date_set_time</literal> is deprecated and should not be used in newly-written code.</para></warning>
<para>
Sets the value of a date from a <link linkend="GTime"><type>GTime</type></link> value.
The time to date conversion is done using the user's current timezone.
</para>
<para>
<parameter>Deprecated</parameter>:2.10: Use <link linkend="g-date-set-time-t"><function>g_date_set_time_t()</function></link> instead.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>date</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GDate"><type>GDate</type></link>.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>time_</parameter>&#160;:</term>
<listitem><simpara> <link linkend="GTime"><type>GTime</type></link> value to set.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-date-set-time-t" role="function" condition="since:2.10">
<title>g_date_set_time_t ()</title>
<indexterm zone="g-date-set-time-t" role="2.10"><primary sortas="date_set_time_t">g_date_set_time_t</primary></indexterm><programlisting><link linkend="void">void</link>                g_date_set_time_t                   (<link linkend="GDate">GDate</link> *date,
                                                         <link linkend="time-t">time_t</link> timet);</programlisting>
<para>
Sets the value of a date to the date corresponding to a time 
specified as a time_t. The time to date conversion is done using 
the user's current timezone.
</para>
<para>
To set the value of a date to the current day, you could write:
<informalexample><programlisting>
 g_date_set_time_t (date, time (NULL)); 
</programlisting></informalexample></para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>date</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GDate"><type>GDate</type></link> 
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>timet</parameter>&#160;:</term>
<listitem><simpara> <type>time_t</type> value to set
</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.10</para></refsect2>
<refsect2 id="g-date-set-time-val" role="function" condition="since:2.10">
<title>g_date_set_time_val ()</title>
<indexterm zone="g-date-set-time-val" role="2.10"><primary sortas="date_set_time_val">g_date_set_time_val</primary></indexterm><programlisting><link linkend="void">void</link>                g_date_set_time_val                 (<link linkend="GDate">GDate</link> *date,
                                                         <link linkend="GTimeVal">GTimeVal</link> *timeval);</programlisting>
<para>
Sets the value of a date from a <link linkend="GTimeVal"><type>GTimeVal</type></link> value.  Note that the
<parameter>tv_usec</parameter> member is ignored, because <link linkend="GDate"><type>GDate</type></link> can't make use of the
additional precision.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>date</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GDate"><type>GDate</type></link> 
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>timeval</parameter>&#160;:</term>
<listitem><simpara> <link linkend="GTimeVal"><type>GTimeVal</type></link> value to set
</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.10</para></refsect2>
<refsect2 id="g-date-set-parse" role="function">
<title>g_date_set_parse ()</title>
<indexterm zone="g-date-set-parse"><primary sortas="date_set_parse">g_date_set_parse</primary></indexterm><programlisting><link linkend="void">void</link>                g_date_set_parse                    (<link linkend="GDate">GDate</link> *date,
                                                         const <link linkend="gchar">gchar</link> *str);</programlisting>
<para>
Parses a user-inputted string <parameter>str</parameter>, and try to figure out what date it
represents, taking the <link linkend="setlocale">current locale</link>
into account. If the string is successfully parsed, the date will be
valid after the call. Otherwise, it will be invalid. You should check
using <link linkend="g-date-valid"><function>g_date_valid()</function></link> to see whether the parsing succeeded.
</para>
<para>
This function is not appropriate for file formats and the like; it
isn't very precise, and its exact behavior varies with the
locale. It's intended to be a heuristic routine that guesses what the
user means by a given string (and it does work pretty well in that
capacity).
</para><variablelist role="params">
<varlistentry><term><parameter>date</parameter>&#160;:</term>
<listitem><simpara>a <link linkend="GDate"><type>GDate</type></link> to fill in
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>str</parameter>&#160;:</term>
<listitem><simpara>string to parse
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-date-add-days" role="function">
<title>g_date_add_days ()</title>
<indexterm zone="g-date-add-days"><primary sortas="date_add_days">g_date_add_days</primary></indexterm><programlisting><link linkend="void">void</link>                g_date_add_days                     (<link linkend="GDate">GDate</link> *date,
                                                         <link linkend="guint">guint</link> n_days);</programlisting>
<para>
Increments a date some number of days. To move forward by weeks, add
weeks*7 days. The date must be valid.
</para><variablelist role="params">
<varlistentry><term><parameter>date</parameter>&#160;:</term>
<listitem><simpara>a <link linkend="GDate"><type>GDate</type></link> to increment
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>n_days</parameter>&#160;:</term>
<listitem><simpara>number of days to move the date forward
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-date-subtract-days" role="function">
<title>g_date_subtract_days ()</title>
<indexterm zone="g-date-subtract-days"><primary sortas="date_subtract_days">g_date_subtract_days</primary></indexterm><programlisting><link linkend="void">void</link>                g_date_subtract_days                (<link linkend="GDate">GDate</link> *date,
                                                         <link linkend="guint">guint</link> n_days);</programlisting>
<para>
Moves a date some number of days into the past. To move by weeks, just
move by weeks*7 days. The date must be valid.
</para><variablelist role="params">
<varlistentry><term><parameter>date</parameter>&#160;:</term>
<listitem><simpara>a <link linkend="GDate"><type>GDate</type></link> to decrement
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>n_days</parameter>&#160;:</term>
<listitem><simpara>number of days to move
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-date-add-months" role="function">
<title>g_date_add_months ()</title>
<indexterm zone="g-date-add-months"><primary sortas="date_add_months">g_date_add_months</primary></indexterm><programlisting><link linkend="void">void</link>                g_date_add_months                   (<link linkend="GDate">GDate</link> *date,
                                                         <link linkend="guint">guint</link> n_months);</programlisting>
<para>
Increments a date by some number of months. If the day of the month is
greater than 28, this routine may change the day of the month (because
the destination month may not have the current day in it). The date
must be valid.
</para><variablelist role="params">
<varlistentry><term><parameter>date</parameter>&#160;:</term>
<listitem><simpara>a <link linkend="GDate"><type>GDate</type></link> to increment
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>n_months</parameter>&#160;:</term>
<listitem><simpara>number of months to move forward
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-date-subtract-months" role="function">
<title>g_date_subtract_months ()</title>
<indexterm zone="g-date-subtract-months"><primary sortas="date_subtract_months">g_date_subtract_months</primary></indexterm><programlisting><link linkend="void">void</link>                g_date_subtract_months              (<link linkend="GDate">GDate</link> *date,
                                                         <link linkend="guint">guint</link> n_months);</programlisting>
<para>
Moves a date some number of months into the past. If the current day of
the month doesn't exist in the destination month, the day of the month
may change. The date must be valid.
</para><variablelist role="params">
<varlistentry><term><parameter>date</parameter>&#160;:</term>
<listitem><simpara>a <link linkend="GDate"><type>GDate</type></link> to decrement
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>n_months</parameter>&#160;:</term>
<listitem><simpara>number of months to move
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-date-add-years" role="function">
<title>g_date_add_years ()</title>
<indexterm zone="g-date-add-years"><primary sortas="date_add_years">g_date_add_years</primary></indexterm><programlisting><link linkend="void">void</link>                g_date_add_years                    (<link linkend="GDate">GDate</link> *date,
                                                         <link linkend="guint">guint</link> n_years);</programlisting>
<para>
Increments a date by some number of years. If the date is February 29,
and the destination year is not a leap year, the date will be changed
to February 28. The date must be valid.
</para><variablelist role="params">
<varlistentry><term><parameter>date</parameter>&#160;:</term>
<listitem><simpara>a <link linkend="GDate"><type>GDate</type></link> to increment
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>n_years</parameter>&#160;:</term>
<listitem><simpara>number of years to move forward
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-date-subtract-years" role="function">
<title>g_date_subtract_years ()</title>
<indexterm zone="g-date-subtract-years"><primary sortas="date_subtract_years">g_date_subtract_years</primary></indexterm><programlisting><link linkend="void">void</link>                g_date_subtract_years               (<link linkend="GDate">GDate</link> *date,
                                                         <link linkend="guint">guint</link> n_years);</programlisting>
<para>
Moves a date some number of years into the past. If the current day
doesn't exist in the destination year (i.e. it's February 29 and you
move to a non-leap-year) then the day is changed to February 29. The date
must be valid.
</para><variablelist role="params">
<varlistentry><term><parameter>date</parameter>&#160;:</term>
<listitem><simpara>a <link linkend="GDate"><type>GDate</type></link> to decrement
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>n_years</parameter>&#160;:</term>
<listitem><simpara>number of years to move
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-date-days-between" role="function">
<title>g_date_days_between ()</title>
<indexterm zone="g-date-days-between"><primary sortas="date_days_between">g_date_days_between</primary></indexterm><programlisting><link linkend="gint">gint</link>                g_date_days_between                 (const <link linkend="GDate">GDate</link> *date1,
                                                         const <link linkend="GDate">GDate</link> *date2);</programlisting>
<para>
Computes the number of days between two dates.
If <parameter>date2</parameter> is prior to <parameter>date1</parameter>, the returned value is negative.
Both dates must be valid.
</para><variablelist role="params">
<varlistentry><term><parameter>date1</parameter>&#160;:</term>
<listitem><simpara>the first date
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>date2</parameter>&#160;:</term>
<listitem><simpara>the second date
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara>the number of days between <parameter>date1</parameter> and <parameter>date2</parameter>
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-date-compare" role="function">
<title>g_date_compare ()</title>
<indexterm zone="g-date-compare"><primary sortas="date_compare">g_date_compare</primary></indexterm><programlisting><link linkend="gint">gint</link>                g_date_compare                      (const <link linkend="GDate">GDate</link> *lhs,
                                                         const <link linkend="GDate">GDate</link> *rhs);</programlisting>
<para>
<link linkend="qsort"><function>qsort()</function></link>-style comparsion function for dates. Both
dates must be valid.
</para><variablelist role="params">
<varlistentry><term><parameter>lhs</parameter>&#160;:</term>
<listitem><simpara>first date to compare
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>rhs</parameter>&#160;:</term>
<listitem><simpara>second date to compare
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara>0 for equal, less than zero if <parameter>lhs</parameter> is less than <parameter>rhs</parameter>,
    greater than zero if <parameter>lhs</parameter> is greater than <parameter>rhs</parameter>
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-date-clamp" role="function">
<title>g_date_clamp ()</title>
<indexterm zone="g-date-clamp"><primary sortas="date_clamp">g_date_clamp</primary></indexterm><programlisting><link linkend="void">void</link>                g_date_clamp                        (<link linkend="GDate">GDate</link> *date,
                                                         const <link linkend="GDate">GDate</link> *min_date,
                                                         const <link linkend="GDate">GDate</link> *max_date);</programlisting>
<para>
If <parameter>date</parameter> is prior to <parameter>min_date</parameter>, sets <parameter>date</parameter> equal to <parameter>min_date</parameter>.
If <parameter>date</parameter> falls after <parameter>max_date</parameter>, sets <parameter>date</parameter> equal to <parameter>max_date</parameter>.
Otherwise, <parameter>date</parameter> is unchanged.
Either of <parameter>min_date</parameter> and <parameter>max_date</parameter> may be <link linkend="NULL--CAPS"><literal>NULL</literal></link>.  All non-<link linkend="NULL--CAPS"><literal>NULL</literal></link> dates
must be valid.
</para><variablelist role="params">
<varlistentry><term><parameter>date</parameter>&#160;:</term>
<listitem><simpara>a <link linkend="GDate"><type>GDate</type></link> to clamp
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>min_date</parameter>&#160;:</term>
<listitem><simpara>minimum accepted value for <parameter>date</parameter>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>max_date</parameter>&#160;:</term>
<listitem><simpara>maximum accepted value for <parameter>date</parameter>
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-date-order" role="function">
<title>g_date_order ()</title>
<indexterm zone="g-date-order"><primary sortas="date_order">g_date_order</primary></indexterm><programlisting><link linkend="void">void</link>                g_date_order                        (<link linkend="GDate">GDate</link> *date1,
                                                         <link linkend="GDate">GDate</link> *date2);</programlisting>
<para>
Checks if <parameter>date1</parameter> is less than or equal to <parameter>date2</parameter>,
and swap the values if this is not the case.
</para><variablelist role="params">
<varlistentry><term><parameter>date1</parameter>&#160;:</term>
<listitem><simpara>the first date
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>date2</parameter>&#160;:</term>
<listitem><simpara>the second date
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-date-get-day" role="function">
<title>g_date_get_day ()</title>
<indexterm zone="g-date-get-day"><primary sortas="date_get_day">g_date_get_day</primary></indexterm><programlisting><link linkend="GDateDay">GDateDay</link>            g_date_get_day                      (const <link linkend="GDate">GDate</link> *date);</programlisting>
<para>
Returns the day of the month. The date must be valid.
</para><variablelist role="params">
<varlistentry><term><parameter>date</parameter>&#160;:</term>
<listitem><simpara>a <link linkend="GDate"><type>GDate</type></link> to extract the day of the month from
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara>day of the month
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-date-get-month" role="function">
<title>g_date_get_month ()</title>
<indexterm zone="g-date-get-month"><primary sortas="date_get_month">g_date_get_month</primary></indexterm><programlisting><link linkend="GDateMonth">GDateMonth</link>          g_date_get_month                    (const <link linkend="GDate">GDate</link> *date);</programlisting>
<para>
Returns the month of the year. The date must be valid.
</para><variablelist role="params">
<varlistentry><term><parameter>date</parameter>&#160;:</term>
<listitem><simpara>a <link linkend="GDate"><type>GDate</type></link> to get the month from
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara>month of the year as a <link linkend="GDateMonth"><type>GDateMonth</type></link>
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-date-get-year" role="function">
<title>g_date_get_year ()</title>
<indexterm zone="g-date-get-year"><primary sortas="date_get_year">g_date_get_year</primary></indexterm><programlisting><link linkend="GDateYear">GDateYear</link>           g_date_get_year                     (const <link linkend="GDate">GDate</link> *date);</programlisting>
<para>
Returns the year of a <link linkend="GDate"><type>GDate</type></link>. The date must be valid.
</para><variablelist role="params">
<varlistentry><term><parameter>date</parameter>&#160;:</term>
<listitem><simpara>a <link linkend="GDate"><type>GDate</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara>year in which the date falls
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-date-get-julian" role="function">
<title>g_date_get_julian ()</title>
<indexterm zone="g-date-get-julian"><primary sortas="date_get_julian">g_date_get_julian</primary></indexterm><programlisting><link linkend="guint32">guint32</link>             g_date_get_julian                   (const <link linkend="GDate">GDate</link> *date);</programlisting>
<para>
Returns the Julian day or "serial number" of the <link linkend="GDate"><type>GDate</type></link>. The
Julian day is simply the number of days since January 1, Year 1; i.e.,
January 1, Year 1 is Julian day 1; January 2, Year 1 is Julian day 2,
etc. The date must be valid.
</para><variablelist role="params">
<varlistentry><term><parameter>date</parameter>&#160;:</term>
<listitem><simpara>a <link linkend="GDate"><type>GDate</type></link> to extract the Julian day from
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara>Julian day
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-date-get-weekday" role="function">
<title>g_date_get_weekday ()</title>
<indexterm zone="g-date-get-weekday"><primary sortas="date_get_weekday">g_date_get_weekday</primary></indexterm><programlisting><link linkend="GDateWeekday">GDateWeekday</link>        g_date_get_weekday                  (const <link linkend="GDate">GDate</link> *date);</programlisting>
<para>
Returns the day of the week for a <link linkend="GDate"><type>GDate</type></link>. The date must be valid.
</para><variablelist role="params">
<varlistentry><term><parameter>date</parameter>&#160;:</term>
<listitem><simpara>a <link linkend="GDate"><type>GDate</type></link>.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara>day of the week as a <link linkend="GDateWeekday"><type>GDateWeekday</type></link>.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-date-get-day-of-year" role="function">
<title>g_date_get_day_of_year ()</title>
<indexterm zone="g-date-get-day-of-year"><primary sortas="date_get_day_of_year">g_date_get_day_of_year</primary></indexterm><programlisting><link linkend="guint">guint</link>               g_date_get_day_of_year              (const <link linkend="GDate">GDate</link> *date);</programlisting>
<para>
Returns the day of the year, where Jan 1 is the first day of the
year. The date must be valid.
</para><variablelist role="params">
<varlistentry><term><parameter>date</parameter>&#160;:</term>
<listitem><simpara>a <link linkend="GDate"><type>GDate</type></link> to extract day of year from
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara>day of the year
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-date-get-days-in-month" role="function">
<title>g_date_get_days_in_month ()</title>
<indexterm zone="g-date-get-days-in-month"><primary sortas="date_get_days_in_month">g_date_get_days_in_month</primary></indexterm><programlisting><link linkend="guint8">guint8</link>              g_date_get_days_in_month            (<link linkend="GDateMonth">GDateMonth</link> month,
                                                         <link linkend="GDateYear">GDateYear</link> year);</programlisting>
<para>
Returns the number of days in a month, taking leap years into account.
</para><variablelist role="params">
<varlistentry><term><parameter>month</parameter>&#160;:</term>
<listitem><simpara>month
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>year</parameter>&#160;:</term>
<listitem><simpara>year
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara>number of days in <parameter>month</parameter> during the <parameter>year</parameter>
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-date-is-first-of-month" role="function">
<title>g_date_is_first_of_month ()</title>
<indexterm zone="g-date-is-first-of-month"><primary sortas="date_is_first_of_month">g_date_is_first_of_month</primary></indexterm><programlisting><link linkend="gboolean">gboolean</link>            g_date_is_first_of_month            (const <link linkend="GDate">GDate</link> *date);</programlisting>
<para>
Returns <link linkend="TRUE--CAPS"><literal>TRUE</literal></link> if the date is on the first of a month. The date must be valid.
</para><variablelist role="params">
<varlistentry><term><parameter>date</parameter>&#160;:</term>
<listitem><simpara>a <link linkend="GDate"><type>GDate</type></link> to check
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara>%TRUE if the date is the first of the month
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-date-is-last-of-month" role="function">
<title>g_date_is_last_of_month ()</title>
<indexterm zone="g-date-is-last-of-month"><primary sortas="date_is_last_of_month">g_date_is_last_of_month</primary></indexterm><programlisting><link linkend="gboolean">gboolean</link>            g_date_is_last_of_month             (const <link linkend="GDate">GDate</link> *date);</programlisting>
<para>
Returns <link linkend="TRUE--CAPS"><literal>TRUE</literal></link> if the date is the last day of the month. The date must be valid.
</para><variablelist role="params">
<varlistentry><term><parameter>date</parameter>&#160;:</term>
<listitem><simpara>a <link linkend="GDate"><type>GDate</type></link> to check
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara>%TRUE if the date is the last day of the month
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-date-is-leap-year" role="function">
<title>g_date_is_leap_year ()</title>
<indexterm zone="g-date-is-leap-year"><primary sortas="date_is_leap_year">g_date_is_leap_year</primary></indexterm><programlisting><link linkend="gboolean">gboolean</link>            g_date_is_leap_year                 (<link linkend="GDateYear">GDateYear</link> year);</programlisting>
<para>
Returns <link linkend="TRUE--CAPS"><literal>TRUE</literal></link> if the year is a leap year.<footnote><para>
For the purposes of this function, leap year is every year divisible by
4 unless that year is divisible by 100. If it is divisible by 100 it would
be a leap year only if that year is also divisible by 400.</para></footnote>
</para><variablelist role="params">
<varlistentry><term><parameter>year</parameter>&#160;:</term>
<listitem><simpara>year to check
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara>%TRUE if the year is a leap year
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-date-get-monday-week-of-year" role="function">
<title>g_date_get_monday_week_of_year ()</title>
<indexterm zone="g-date-get-monday-week-of-year"><primary sortas="date_get_monday_week_of_year">g_date_get_monday_week_of_year</primary></indexterm><programlisting><link linkend="guint">guint</link>               g_date_get_monday_week_of_year      (const <link linkend="GDate">GDate</link> *date);</programlisting>
<para>
Returns the week of the year, where weeks are understood to start on
Monday. If the date is before the first Monday of the year, return
0. The date must be valid.
</para><variablelist role="params">
<varlistentry><term><parameter>date</parameter>&#160;:</term>
<listitem><simpara>a <link linkend="GDate"><type>GDate</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara>week of the year
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-date-get-monday-weeks-in-year" role="function">
<title>g_date_get_monday_weeks_in_year ()</title>
<indexterm zone="g-date-get-monday-weeks-in-year"><primary sortas="date_get_monday_weeks_in_year">g_date_get_monday_weeks_in_year</primary></indexterm><programlisting><link linkend="guint8">guint8</link>              g_date_get_monday_weeks_in_year     (<link linkend="GDateYear">GDateYear</link> year);</programlisting>
<para>
Returns the number of weeks in the year, where weeks are taken to start
on Monday. Will be 52 or 53. The date must be valid. (Years always have 52
7-day periods, plus 1 or 2 extra days depending on whether it's a leap
year. This function is basically telling you how many Mondays are in
the year, i.e. there are 53 Mondays if one of the extra days happens
to be a Monday.)
</para><variablelist role="params">
<varlistentry><term><parameter>year</parameter>&#160;:</term>
<listitem><simpara>a year
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara>number of Mondays in the year
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-date-get-sunday-week-of-year" role="function">
<title>g_date_get_sunday_week_of_year ()</title>
<indexterm zone="g-date-get-sunday-week-of-year"><primary sortas="date_get_sunday_week_of_year">g_date_get_sunday_week_of_year</primary></indexterm><programlisting><link linkend="guint">guint</link>               g_date_get_sunday_week_of_year      (const <link linkend="GDate">GDate</link> *date);</programlisting>
<para>
Returns the week of the year during which this date falls, if weeks
are understood to being on Sunday. The date must be valid. Can return 0 if
the day is before the first Sunday of the year.
</para><variablelist role="params">
<varlistentry><term><parameter>date</parameter>&#160;:</term>
<listitem><simpara>a <link linkend="GDate"><type>GDate</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara>week number
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-date-get-sunday-weeks-in-year" role="function">
<title>g_date_get_sunday_weeks_in_year ()</title>
<indexterm zone="g-date-get-sunday-weeks-in-year"><primary sortas="date_get_sunday_weeks_in_year">g_date_get_sunday_weeks_in_year</primary></indexterm><programlisting><link linkend="guint8">guint8</link>              g_date_get_sunday_weeks_in_year     (<link linkend="GDateYear">GDateYear</link> year);</programlisting>
<para>
Returns the number of weeks in the year, where weeks are taken to start
on Sunday. Will be 52 or 53. The date must be valid. (Years always have 52
7-day periods, plus 1 or 2 extra days depending on whether it's a leap
year. This function is basically telling you how many Sundays are in
the year, i.e. there are 53 Sundays if one of the extra days happens
to be a Sunday.)
</para><variablelist role="params">
<varlistentry><term><parameter>year</parameter>&#160;:</term>
<listitem><simpara>year to count weeks in
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara>number of weeks
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-date-get-iso8601-week-of-year" role="function" condition="since:2.6">
<title>g_date_get_iso8601_week_of_year ()</title>
<indexterm zone="g-date-get-iso8601-week-of-year" role="2.6"><primary sortas="date_get_iso8601_week_of_year">g_date_get_iso8601_week_of_year</primary></indexterm><programlisting><link linkend="guint">guint</link>               g_date_get_iso8601_week_of_year     (const <link linkend="GDate">GDate</link> *date);</programlisting>
<para>
Returns the week of the year, where weeks are interpreted according
to ISO 8601.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>date</parameter>&#160;:</term>
<listitem><simpara> a valid <link linkend="GDate"><type>GDate</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> ISO 8601 week number of the year.

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.6</para></refsect2>
<refsect2 id="g-date-strftime" role="function">
<title>g_date_strftime ()</title>
<indexterm zone="g-date-strftime"><primary sortas="date_strftime">g_date_strftime</primary></indexterm><programlisting><link linkend="gsize">gsize</link>               g_date_strftime                     (<link linkend="gchar">gchar</link> *s,
                                                         <link linkend="gsize">gsize</link> slen,
                                                         const <link linkend="gchar">gchar</link> *format,
                                                         const <link linkend="GDate">GDate</link> *date);</programlisting>
<para>
Generates a printed representation of the date, in a
<link linkend="setlocale">locale</link>-specific way. Works just like
the platform's C library <link linkend="strftime"><function>strftime()</function></link> function, but only accepts date-related
formats; time-related formats give undefined results. Date must be valid.
Unlike <link linkend="strftime"><function>strftime()</function></link> (which uses the locale encoding), works on a UTF-8 format
string and stores a UTF-8 result.
</para>
<para>
This function does not provide any conversion specifiers in addition
to those implemented by the platform's C library. For example, don't
expect that using <link linkend="g-date-strftime"><function>g_date_strftime()</function></link> would make the <link linkend="F--CAPS"><literal>F</literal></link> provided by the C99
<link linkend="strftime"><function>strftime()</function></link> work on Windows where the C library only complies to C89.
</para><variablelist role="params">
<varlistentry><term><parameter>s</parameter>&#160;:</term>
<listitem><simpara>destination buffer
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>slen</parameter>&#160;:</term>
<listitem><simpara>buffer size
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>format</parameter>&#160;:</term>
<listitem><simpara>format string
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>date</parameter>&#160;:</term>
<listitem><simpara>valid <link linkend="GDate"><type>GDate</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara>number of characters written to the buffer, or 0 the buffer was too small
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-date-to-struct-tm" role="function">
<title>g_date_to_struct_tm ()</title>
<indexterm zone="g-date-to-struct-tm"><primary sortas="date_to_struct_tm">g_date_to_struct_tm</primary></indexterm><programlisting><link linkend="void">void</link>                g_date_to_struct_tm                 (const <link linkend="GDate">GDate</link> *date,
                                                         <link linkend="struct-tm">struct tm</link> *tm);</programlisting>
<para>
Fills in the date-related bits of a <structname>struct tm</structname>
using the <parameter>date</parameter> value. Initializes the non-date parts with something
sane but meaningless.
</para><variablelist role="params">
<varlistentry><term><parameter>date</parameter>&#160;:</term>
<listitem><simpara>a <link linkend="GDate"><type>GDate</type></link> to set the <structname>struct tm</structname> from.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>tm</parameter>&#160;:</term>
<listitem><simpara><structname>struct tm</structname> to fill.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-date-valid" role="function">
<title>g_date_valid ()</title>
<indexterm zone="g-date-valid"><primary sortas="date_valid">g_date_valid</primary></indexterm><programlisting><link linkend="gboolean">gboolean</link>            g_date_valid                        (const <link linkend="GDate">GDate</link> *date);</programlisting>
<para>
Returns <link linkend="TRUE--CAPS"><literal>TRUE</literal></link> if the <link linkend="GDate"><type>GDate</type></link> represents an existing day. The date must not
contain garbage; it should have been initialized with <link linkend="g-date-clear"><function>g_date_clear()</function></link>
if it wasn't allocated by one of the <link linkend="g-date-new"><function>g_date_new()</function></link> variants.
</para><variablelist role="params">
<varlistentry><term><parameter>date</parameter>&#160;:</term>
<listitem><simpara>a <link linkend="GDate"><type>GDate</type></link> to check
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara>Whether the date is valid
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-date-valid-day" role="function">
<title>g_date_valid_day ()</title>
<indexterm zone="g-date-valid-day"><primary sortas="date_valid_day">g_date_valid_day</primary></indexterm><programlisting><link linkend="gboolean">gboolean</link>            g_date_valid_day                    (<link linkend="GDateDay">GDateDay</link> day);</programlisting>
<para>
Returns <link linkend="TRUE--CAPS"><literal>TRUE</literal></link> if the day of the month is valid (a day is valid if it's
between 1 and 31 inclusive).
</para><variablelist role="params">
<varlistentry><term><parameter>day</parameter>&#160;:</term>
<listitem><simpara>day to check
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara>%TRUE if the day is valid
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-date-valid-month" role="function">
<title>g_date_valid_month ()</title>
<indexterm zone="g-date-valid-month"><primary sortas="date_valid_month">g_date_valid_month</primary></indexterm><programlisting><link linkend="gboolean">gboolean</link>            g_date_valid_month                  (<link linkend="GDateMonth">GDateMonth</link> month);</programlisting>
<para>
Returns <link linkend="TRUE--CAPS"><literal>TRUE</literal></link> if the month value is valid. The 12 <link linkend="GDateMonth"><type>GDateMonth</type></link>
enumeration values are the only valid months.
</para><variablelist role="params">
<varlistentry><term><parameter>month</parameter>&#160;:</term>
<listitem><simpara>month
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara>%TRUE if the month is valid
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-date-valid-year" role="function">
<title>g_date_valid_year ()</title>
<indexterm zone="g-date-valid-year"><primary sortas="date_valid_year">g_date_valid_year</primary></indexterm><programlisting><link linkend="gboolean">gboolean</link>            g_date_valid_year                   (<link linkend="GDateYear">GDateYear</link> year);</programlisting>
<para>
Returns <link linkend="TRUE--CAPS"><literal>TRUE</literal></link> if the year is valid. Any year greater than 0 is valid,
though there is a 16-bit limit to what <link linkend="GDate"><type>GDate</type></link> will understand.
</para><variablelist role="params">
<varlistentry><term><parameter>year</parameter>&#160;:</term>
<listitem><simpara>year
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara>%TRUE if the year is valid
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-date-valid-dmy" role="function">
<title>g_date_valid_dmy ()</title>
<indexterm zone="g-date-valid-dmy"><primary sortas="date_valid_dmy">g_date_valid_dmy</primary></indexterm><programlisting><link linkend="gboolean">gboolean</link>            g_date_valid_dmy                    (<link linkend="GDateDay">GDateDay</link> day,
                                                         <link linkend="GDateMonth">GDateMonth</link> month,
                                                         <link linkend="GDateYear">GDateYear</link> year);</programlisting>
<para>
Returns <link linkend="TRUE--CAPS"><literal>TRUE</literal></link> if the day-month-year triplet forms a valid, existing day
in the range of days <link linkend="GDate"><type>GDate</type></link> understands (Year 1 or later, no more than
a few thousand years in the future).
</para><variablelist role="params">
<varlistentry><term><parameter>day</parameter>&#160;:</term>
<listitem><simpara>day
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>month</parameter>&#160;:</term>
<listitem><simpara>month
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>year</parameter>&#160;:</term>
<listitem><simpara>year
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara>%TRUE if the date is a valid one
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-date-valid-julian" role="function">
<title>g_date_valid_julian ()</title>
<indexterm zone="g-date-valid-julian"><primary sortas="date_valid_julian">g_date_valid_julian</primary></indexterm><programlisting><link linkend="gboolean">gboolean</link>            g_date_valid_julian                 (<link linkend="guint32">guint32</link> julian_date);</programlisting>
<para>
Returns <link linkend="TRUE--CAPS"><literal>TRUE</literal></link> if the Julian day is valid. Anything greater than zero
is basically a valid Julian, though there is a 32-bit limit.
</para><variablelist role="params">
<varlistentry><term><parameter>julian_date</parameter>&#160;:</term>
<listitem><simpara>Julian day to check
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara>%TRUE if the Julian day is valid
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-date-valid-weekday" role="function">
<title>g_date_valid_weekday ()</title>
<indexterm zone="g-date-valid-weekday"><primary sortas="date_valid_weekday">g_date_valid_weekday</primary></indexterm><programlisting><link linkend="gboolean">gboolean</link>            g_date_valid_weekday                (<link linkend="GDateWeekday">GDateWeekday</link> weekday);</programlisting>
<para>
Returns <link linkend="TRUE--CAPS"><literal>TRUE</literal></link> if the weekday is valid. The seven <link linkend="GDateWeekday"><type>GDateWeekday</type></link> enumeration
values are the only valid weekdays.
</para><variablelist role="params">
<varlistentry><term><parameter>weekday</parameter>&#160;:</term>
<listitem><simpara>weekday
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara>%TRUE if the weekday is valid
</simpara></listitem></varlistentry>
</variablelist></refsect2>

</refsect1>




</refentry>
