mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-15 03:58:04 +02:00
Point out time_t vs GTime pitfalls.
2005-08-22 Matthias Clasen <mclasen@redhat.com> * glib/tmpl/date.sgml: Point out time_t vs GTime pitfalls.
This commit is contained in:
parent
8680e1fe10
commit
d7a216df8f
@ -1,3 +1,7 @@
|
|||||||
|
2005-08-22 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* glib/tmpl/date.sgml: Point out time_t vs GTime pitfalls.
|
||||||
|
|
||||||
2005-08-15 Matthias Clasen <mclasen@redhat.com>
|
2005-08-15 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
* glib/glib-gettexttize.xml:
|
* glib/glib-gettexttize.xml:
|
||||||
|
@ -53,9 +53,9 @@ representation is valid. Sometimes neither is valid. Use the API.
|
|||||||
|
|
||||||
<para>
|
<para>
|
||||||
GLib doesn't contain any time-manipulation functions; however, there
|
GLib doesn't contain any time-manipulation functions; however, there
|
||||||
is a #GTime typedef which is equivalent to <type>time_t</type>, and a #GTimeVal
|
is a #GTime typedef and a #GTimeVal struct which represents a more
|
||||||
struct which represents a more precise time (with microseconds). You
|
precise time (with microseconds). You can request the current time as
|
||||||
can request the current time as a #GTimeVal with g_get_current_time().
|
a #GTimeVal with g_get_current_time().
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<!-- ##### SECTION See_Also ##### -->
|
<!-- ##### SECTION See_Also ##### -->
|
||||||
@ -76,9 +76,9 @@ code readability.
|
|||||||
|
|
||||||
<!-- ##### STRUCT GTimeVal ##### -->
|
<!-- ##### STRUCT GTimeVal ##### -->
|
||||||
<para>
|
<para>
|
||||||
Represents a precise time, with seconds and microseconds. Same as the
|
Represents a precise time, with seconds and microseconds.
|
||||||
<structname>struct timeval</structname> returned by the
|
Similar to the <structname>struct timeval</structname> returned by
|
||||||
<function>gettimeofday()</function> UNIX call.
|
the <function>gettimeofday()</function> UNIX call.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@tv_sec: seconds.
|
@tv_sec: seconds.
|
||||||
@ -139,6 +139,24 @@ month, and year.
|
|||||||
Simply a replacement for <type>time_t</type>. Unrelated to #GTimer.
|
Simply a replacement for <type>time_t</type>. Unrelated to #GTimer.
|
||||||
</para>
|
</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>GType</type> will overflow in the year 2038, and
|
||||||
|
you cannot use the address of a <type>GTime</type> variable as argument
|
||||||
|
to the UNIX time() function. Instead, do the following:
|
||||||
|
<informalexample>
|
||||||
|
<programlisting>
|
||||||
|
time_t ttime;
|
||||||
|
GTime gtime;
|
||||||
|
|
||||||
|
time (&ttime);
|
||||||
|
gtime = (GTime)ttime;
|
||||||
|
</programlisting>
|
||||||
|
</informalexample>
|
||||||
|
</para>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- ##### ENUM GDateDMY ##### -->
|
<!-- ##### ENUM GDateDMY ##### -->
|
||||||
<para>
|
<para>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user