unixdev.net


Switch to SpeakEasy.net DSL

The Modular Manual Browser

Home Page
Manual: (HP-UX-11.11)
Page:
Section:
Apropos / Subsearch:
optional field



 gettimeofday(2)					     gettimeofday(2)




 NAME
      gettimeofday - get the date and time

 SYNOPSIS
      #include <&lt&lt&lt;sys/time.h>&gt&gt&gt;

      int gettimeofday(struct timeval *tp, void *tzp);

 DESCRIPTION
      The gettimeofday() function obtains the current time, expressed as
      seconds and microseconds since 00:00 Coordinated Universal Time (UTC),
      January  1, 1970, and stores it in the timeval structure pointed to by
      tp.  The resolution of the system clock is unspecified.

      If tzp is not a null pointer, the application is not a UNIX-conforming
      application.  See the HP-UX EXTENSIONS section for treatment of a
      non-null pointer for the tzp argument.

 RETURN VALUE
      The gettimeofday() function returns 0 and no value is reserved to
      indicate an error.  See the HP-UX EXTENSIONS section for function
      return values under HP-UX.

 ERRORS
      No errors are defined.  See the HP-UX EXTENSIONS section for error
      values under HP-UX.

 SEE ALSO
      ctime(3C), date(1), ftime(2), stime(2), time(2), <sys/time.h>.

 CHANGE HISTORY
      First released in Issue 4, Version 2.






















				    - 1 -	  Formatted:  August 2, 2006






 gettimeofday(2)					     gettimeofday(2)




				 HP-UX EXTENSIONS



 SYNOPSIS
      #include <&lt&lt&lt;sys/time.h>&gt&gt&gt;

      int gettimeofday(struct timeval *tp,
		       struct timezone *tzp);

 DESCRIPTION
      When gettimeofday() is called under HP-UX, extensions apply to the
      time zone parameter, the return value, and errors.

      If the tzp parameter is not a null pointer, it is interpreted as a
      pointer to a struct timezone under HP-UX.	 The struct timezone has the
      following fields:

      tz_minuteswest   The number of minutes that the local time zone is
		       west of UTC.

      tz_dsttime       A flag that, if nonzero, indicates that Daylight
		       Savings Time (DST) applies locally during the
		       appropriate part of the year.

      Programs should use this time zone information only in the absence of
      the TZ environment variable.

    Security Restrictions
      Only a user with appropriate privileges can set the time of day.

 RETURN VALUE
      gettimeofday() return the following values under HP-UX:

	    0	Successful completion.
	   -1	Failure.  errno is set to indicate the error.

 ERRORS
      If gettimeofday() fails, errno is set to the following value under
      HP-UX:

	   [EFAULT]	  An argument address referenced invalid memory.
			  The reliable detection of this error is
			  implementation dependent.

 EXAMPLES
      The following HP-UX example calls gettimeofday() twice.  It then
      computes the lapsed time between the calls in seconds and microseconds
      and stores the result in a timeval structure:





 Hewlett-Packard Company	    - 1 -   HP-UX Release 11i: November 2000






 gettimeofday(2)					     gettimeofday(2)




	   struct timeval  first,
			   second,
			   lapsed;

	   struct timezone tzp;

	      gettimeofday (&&amp&amp&amp;first, &&amp&amp&amp;tzp);

	   /* lapsed time */

	      gettimeofday (&&amp&amp&amp;second, &&amp&amp&amp;tzp);

	   if (first.tv_usec >&gt&gt&gt; second.tv_usec) {
	      second.tv_usec += 1000000;
	      second.tv_sec--;
	   }

	   lapsed.tv_usec = second.tv_usec - first.tv_usec;
	   lapsed.tv_sec  = second.tv_sec  - first.tv_sec;

 WARNINGS
      The microsecond value usually has a granularity much greater than one
      due to the resolution of the system clock.  Relying on any granularity
      (particularly of one) will render code nonportable.

 AUTHOR
      gettimeofday() was developed by the University of California,
      Berkeley, and HP.

 SEE ALSO
      ctime(3C), date(1), ftime(2), stime(2), time(2), <sys/time.h>.























 Hewlett-Packard Company	    - 2 -   HP-UX Release 11i: November 2000