Changeset 1409:9541a6d7f041


Ignore:
Timestamp:
11/08/09 09:46:51 (2 years ago)
Author:
niam
Branch:
default
Message:

tools::time: current time in milliseconds

Location:
sources
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sources/include/libdodo/toolsTime.h

    r1406 r1409  
    137137 
    138138            /** 
     139             * @return number of milliseconds from 00:00:00 UTC, January 1, 1970 till now 
     140             */ 
     141            static unsigned long millinow(); 
     142 
     143            /** 
    139144             * @return dates of the week 
    140145             * @param date defines timestamp in the weekv 
  • sources/include/libdodo/toolsTimeEx.h

    r1406 r1409  
    4343            TIMEEX_BYFORMAT, 
    4444            TIMEEX_NOW, 
     45            TIMEEX_MILLINOW, 
    4546            TIMEEX_MAKETIME, 
    4647        }; 
  • sources/src/toolsTime.cc

    r1406 r1409  
    3434#include <stdlib.h> 
    3535#include <errno.h> 
     36#include <sys/time.h> 
    3637 
    3738#include <libdodo/toolsTime.h> 
     
    9697//------------------------------------------------------------------- 
    9798 
     99unsigned long 
     100tools::time::millinow() 
     101{ 
     102    timeval tv; 
     103 
     104    if (gettimeofday(&tv, NULL) == -1) 
     105        throw exception::basic(exception::MODULE_TOOLSTIME, TIMEEX_MILLINOW, exception::ERRNO_ERRNO, errno, strerror(errno), __LINE__, __FILE__); 
     106 
     107    return 1000 * tv.tv_sec + tv.tv_usec / 1000; 
     108} 
     109 
     110//------------------------------------------------------------------- 
     111 
    98112long 
    99113tools::time::now() 
Note: See TracChangeset for help on using the changeset viewer.