gettimeofday

GETTIMEOFDAY(2)            Linux Programmer's Manual           GETTIMEOFDAY(2)



åå
       gettimeofday, settimeofday - æéãåå¾/è¨å®ãã

æ¸å¼
       #include <sys/time.h>
       #include <unistd.h>

       int gettimeofday(struct timeval *tv, struct timezone *tz);
       int settimeofday(const struct timeval *tv , const struct timezone *tz);

説æ
       gettimeofday 㨠settimeofday ã¯æéã¨ã¿ã¤ã ã¾ã¼ã³(timezone)ãåå¾ã¾ãã¯è¨‐
       å®ããã tv 㯠/usr/include/sys/time.h ã«å®ç¾©ããã¦ãã timeval æ§é ä½ã§ãã:

       struct timeval {
                      long tv_sec;        /* seconds */
                      long tv_usec;  /* microseconds */
                      };

       ãã㦠tz 㯠timezone æ§é ä½ã§ãã:

       struct timezone {
                       int  tz_minuteswest;
                       /* minutes west of Greenwich */
                       int  tz_dsttime;
                       /* type of dst correction */
                       };

       å¤æé(daylight savings times)ã¯ä»¥ä¸ã®ããã«å®ç¾©ããã:

       DST_NONE /* not on dst */
       DST_USA    /* USA style dst */
       DST_AUST   /* Australian style dst */
       DST_WET /* Western European dst */
       DST_MET /* Middle European dst */
       DST_EET /* Eastern European dst */
       DST_CAN /* Canada */
       DST_GB     /* Great Britain and Eire */
       DST_RUM /* Rumania */
       DST_TUR /* Turkey */
       DST_AUSTALT     /* Australian style with shift in 1986 */

       ãããæä½ããããã«ä»¥ä¸ã®ãã¯ã(macro)ãå®ç¾©ããã¦ãã :
       #define   timerisset(tvp)\
                  ((tvp)->tv_sec || (tvp)->tv_usec)
       #define   timercmp(tvp, uvp, cmp)\
                  ((tvp)->tv_sec cmp (uvp)->tv_sec ||\
                  (tvp)->tv_sec == (uvp)->tv_sec &&\
                  (tvp)->tv_usec cmp (uvp)->tv_usec)
          #define timerclear(tvp)
                  ((tvp)->tv_sec = (tvp)->tv_usec = 0)

       tv ã¾ã㯠tz ã®ã©ã¡ããã NULL ãªãã°ã対å¿ããæ§é ä½ã¯è¨å®ãããªããè¿ãããªãã

       ã¹ã¼ãã¼ã»ã¦ã¼ã¶ã¼ã®ã¿ã settimeofday ã使ç¨ã§ããã

è¿ãå¤
       getimeofday 㨠settimeofday ã¯æåããã¨ã¼ããè¿ãã失æããå ´å㯠-1
       ãè¿ã(ãã®å ´å㯠errno ãé©åã«è¨å®ããã)ã

ã¨ã©ã¼
       EPERM  settimeofday ãã¹ã¼ãã¼ã»ã¦ã¼ã¶ã¼ä»¥å¤ããå¼ã³åºãããã

       EINVAL ã¿ã¤ã ã¾ã¼ã³(ã¾ãã¯ä»ã®ä½ã)ãä¸æ£ã§ããã

       EFAULT tv ã tz ã®ã©ã¡ãããã¢ã¯ã»ã¹å¯è½ãªã¢ãã¬ã¹ç©ºéã®å¤é¨ãæãã¦ããã


æºæ
       SVr4, BSD 4.3

é¢é£é ç®
       date(1), adjtimex(2), time(2), ctime(3), ftime(3)



Linux 2.0.21                    14 January 1997                GETTIMEOFDAY(2)