Class TimeVal

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") @Deprecated public class TimeVal extends ProxyInstance
Deprecated.
Use GDateTime or guint64 instead.

Represents a precise time, with seconds and microseconds.

Similar to the struct timeval returned by the gettimeofday() UNIX system call.

GLib is attempting to unify around the use of 64-bit integers to represent microsecond-precision time. As such, this type will be removed from a future version of GLib. A consequence of using glong for tv_sec is that on 32-bit systems GTimeVal is subject to the year 2038 problem.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Deprecated.
    Allocate a new TimeVal.
    TimeVal(int tvSec, int tvUsec)
    Deprecated.
    Allocate a new TimeVal with the fields set to the provided values.
    TimeVal(int tvSec, int tvUsec, Arena arena)
    Deprecated.
    Allocate a new TimeVal with the fields set to the provided values.
    TimeVal(Arena arena)
    Deprecated.
    Allocate a new TimeVal.
    Deprecated.
    Create a TimeVal proxy instance for the provided memory address.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(int microseconds)
    Deprecated.
    GTimeVal is not year-2038-safe.
    static boolean
    fromIso8601(String isoDate, TimeVal time)
    Deprecated.
    GTimeVal is not year-2038-safe.
    Deprecated.
    The memory layout of the native struct.
    int
    Deprecated.
    Read the value of the field tv_sec.
    int
    Deprecated.
    Read the value of the field tv_usec.
    @Nullable String
    Deprecated.
    GTimeVal is not year-2038-safe.
    void
    writeTvSec(int tvSec)
    Deprecated.
    Write a value in the field tv_sec.
    void
    writeTvUsec(int tvUsec)
    Deprecated.
    Write a value in the field tv_usec.

    Methods inherited from class ProxyInstance

    equals, handle, hashCode

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • TimeVal

      public TimeVal(MemorySegment address)
      Deprecated.
      Create a TimeVal proxy instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • TimeVal

      public TimeVal(Arena arena)
      Deprecated.
      Allocate a new TimeVal.
      Parameters:
      arena - to control the memory allocation scope
    • TimeVal

      public TimeVal()
      Deprecated.
      Allocate a new TimeVal. The memory is allocated with Arena.ofAuto().
    • TimeVal

      public TimeVal(int tvSec, int tvUsec, Arena arena)
      Deprecated.
      Allocate a new TimeVal with the fields set to the provided values.
      Parameters:
      tvSec - value for the field tvSec
      tvUsec - value for the field tvUsec
      arena - to control the memory allocation scope
    • TimeVal

      public TimeVal(int tvSec, int tvUsec)
      Deprecated.
      Allocate a new TimeVal with the fields set to the provided values. The memory is allocated with Arena.ofAuto().
      Parameters:
      tvSec - value for the field tvSec
      tvUsec - value for the field tvUsec
  • Method Details

    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      Deprecated.
      The memory layout of the native struct.
      Returns:
      the memory layout
    • readTvSec

      public int readTvSec()
      Deprecated.
      Read the value of the field tv_sec.
      Returns:
      The value of the field tv_sec
    • writeTvSec

      public void writeTvSec(int tvSec)
      Deprecated.
      Write a value in the field tv_sec.
      Parameters:
      tvSec - The new value for the field tv_sec
    • readTvUsec

      public int readTvUsec()
      Deprecated.
      Read the value of the field tv_usec.
      Returns:
      The value of the field tv_usec
    • writeTvUsec

      public void writeTvUsec(int tvUsec)
      Deprecated.
      Write a value in the field tv_usec.
      Parameters:
      tvUsec - The new value for the field tv_usec
    • fromIso8601

      @Deprecated public static boolean fromIso8601(String isoDate, TimeVal time)
      Deprecated.
      GTimeVal is not year-2038-safe. Use g_date_time_new_from_iso8601() instead.

      Converts a string containing an ISO 8601 encoded date and time to a GTimeVal and puts it into time.

      isoDate must include year, month, day, hours, minutes, and seconds. It can optionally include fractions of a second and a time zone indicator. (In the absence of any time zone indication, the timestamp is assumed to be in local time.)

      Any leading or trailing space in isoDate is ignored.

      This function was deprecated, along with GTimeVal itself, in GLib 2.62. Equivalent functionality is available using code like:

      GDateTime *dt = g_date_time_new_from_iso8601 (iso8601_string, NULL);
      gint64 time_val = g_date_time_to_unix (dt);
      g_date_time_unref (dt);
      
      Parameters:
      isoDate - an ISO 8601 encoded date string
      time - a GTimeVal
      Returns:
      true if the conversion was successful.
      Since:
      2.12
    • add

      @Deprecated public void add(int microseconds)
      Deprecated.
      GTimeVal is not year-2038-safe. Use guint64 for representing microseconds since the epoch, or use GDateTime.
      Adds the given number of microseconds to time. microseconds can also be negative to decrease the value of time.
      Parameters:
      microseconds - number of microseconds to add to time
    • toIso8601

      @Deprecated public @Nullable String toIso8601()
      Deprecated.
      GTimeVal is not year-2038-safe. Use g_date_time_format_iso8601(dt) instead.

      Converts this TimeVal into an RFC 3339 encoded string, relative to the Coordinated Universal Time (UTC). This is one of the many formats allowed by ISO 8601.

      ISO 8601 allows a large number of date/time formats, with or without punctuation and optional elements. The format returned by this function is a complete date and time, with optional punctuation included, the UTC time zone represented as "Z", and the tvUsec part included if and only if it is nonzero, i.e. either "YYYY-MM-DDTHH:MM:SSZ" or "YYYY-MM-DDTHH:MM:SS.fffffZ".

      This corresponds to the Internet date/time format defined by RFC 3339, and to either of the two most-precise formats defined by the W3C Note Date and Time Formats. Both of these documents are profiles of ISO 8601.

      Use g_date_time_format() or g_strdup_printf() if a different variation of ISO 8601 format is required.

      If this TimeVal represents a date which is too large to fit into a struct tm, null will be returned. This is platform dependent. Note also that since GTimeVal stores the number of seconds as a glong, on 32-bit systems it is subject to the year 2038 problem. Accordingly, since GLib 2.62, this function has been deprecated. Equivalent functionality is available using:

      GDateTime *dt = g_date_time_new_from_unix_utc (time_val);
      iso8601_string = g_date_time_format_iso8601 (dt);
      g_date_time_unref (dt);
      

      The return value of g_time_val_to_iso8601() has been nullable since GLib 2.54; before then, GLib would crash under the same conditions.

      Returns:
      a newly allocated string containing an ISO 8601 date, or null if this TimeVal was too large
      Since:
      2.12