VirtualBox

Changeset 26209 in vbox


Ignore:
Timestamp:
Feb 3, 2010 4:54:41 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
57234
Message:

IPRT: Added RTTimeSet.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/time.h

    r25857 r26209  
    602602 *
    603603 * @returns pTime.
    604  * @param   pTime   Where to store the time.
     604 * @param   pTime       Where to store the time.
    605605 */
    606606RTDECL(PRTTIMESPEC) RTTimeNow(PRTTIMESPEC pTime);
     607
     608/**
     609 * Sets the system time.
     610 *
     611 * @returns IPRT status code
     612 * @param   pTime       The new system time (UTC).
     613 *
     614 * @remarks This will usually fail because changing the wall time is usually
     615 *          requires extra privileges.
     616 */
     617RTDECL(int) RTTimeSet(PCRTTIMESPEC pTime);
    607618
    608619/**
  • trunk/src/VBox/Runtime/Makefile.kmk

    r26180 r26209  
    487487        r3/posix/rand-posix.cpp \
    488488        r3/posix/RTTimeNow-posix.cpp \
     489        r3/posix/RTTimeSet-posix.cpp \
    489490        r3/posix/semrw-posix.cpp \
    490491        r3/posix/thread-posix.cpp \
     
    558559        r3/posix/process-posix.cpp \
    559560        r3/posix/RTTimeNow-posix.cpp \
     561        r3/posix/RTTimeSet-posix.cpp \
    560562        r3/posix/timelocal-posix.cpp \
    561563        r3/posix/utf8-posix.cpp
     
    589591        r3/posix/RTFileQueryFsSizes-posix.cpp \
    590592        r3/posix/RTSystemQueryOSInfo-posix.cpp \
     593        r3/posix/RTTimeSet-posix.cpp \
    591594        r3/posix/dir-posix.cpp \
    592595        r3/posix/env-posix.cpp \
     
    645648        r3/posix/RTMpGetCount-posix.cpp \
    646649        r3/posix/RTTimeNow-posix.cpp \
     650        r3/posix/RTTimeSet-posix.cpp \
    647651        r3/posix/semevent-posix.cpp \
    648652        r3/posix/semeventmulti-posix.cpp \
     
    682686        r3/posix/rand-posix.cpp \
    683687        r3/posix/RTTimeNow-posix.cpp \
     688        r3/posix/RTTimeSet-posix.cpp \
    684689        r3/posix/semevent-posix.cpp \
    685690        r3/posix/semeventmulti-posix.cpp \
     
    749754        r3/posix/rand-posix.cpp \
    750755        r3/posix/RTTimeNow-posix.cpp \
     756        r3/posix/RTTimeSet-posix.cpp \
    751757        r3/posix/time-posix.cpp \
    752758        r3/posix/timelocal-posix.cpp
  • trunk/src/VBox/Runtime/r3/darwin/time-darwin.cpp

    r15870 r26209  
    9898
    9999
    100 /**
    101  * Gets the current nanosecond timestamp.
    102  *
    103  * This differs from RTTimeNanoTS in that it will use system APIs and not do any
    104  * resolution or performance optimizations.
    105  *
    106  * @returns nanosecond timestamp.
    107  */
    108100RTDECL(uint64_t) RTTimeSystemNanoTS(void)
    109101{
     
    112104
    113105
    114 /**
    115  * Gets the current millisecond timestamp.
    116  *
    117  * This differs from RTTimeNanoTS in that it will use system APIs and not do any
    118  * resolution or performance optimizations.
    119  *
    120  * @returns millisecond timestamp.
    121  */
    122106RTDECL(uint64_t) RTTimeSystemMilliTS(void)
    123107{
     
    126110
    127111
    128 /**
    129  * Gets the current system time.
    130  *
    131  * @returns pTime.
    132  * @param   pTime   Where to store the time.
    133  */
    134112RTDECL(PRTTIMESPEC) RTTimeNow(PRTTIMESPEC pTime)
    135113{
  • trunk/src/VBox/Runtime/r3/win/time-win.cpp

    r20736 r26209  
    136136
    137137
    138 /**
    139  * Gets the current nanosecond timestamp.
    140  *
    141  * This differs from RTTimeNanoTS in that it will use system APIs and not do any
    142  * resolution or performance optimizations.
    143  *
    144  * @returns nanosecond timestamp.
    145  */
    146138RTDECL(uint64_t) RTTimeSystemNanoTS(void)
    147139{
     
    150142
    151143
    152 /**
    153  * Gets the current millisecond timestamp.
    154  *
    155  * This differs from RTTimeNanoTS in that it will use system APIs and not do any
    156  * resolution or performance optimizations.
    157  *
    158  * @returns millisecond timestamp.
    159  */
    160144RTDECL(uint64_t) RTTimeSystemMilliTS(void)
    161145{
     
    164148
    165149
    166 /**
    167  * Gets the current system time.
    168  *
    169  * @returns pTime.
    170  * @param   pTime   Where to store the time.
    171  */
    172150RTDECL(PRTTIMESPEC) RTTimeNow(PRTTIMESPEC pTime)
    173151{
     
    179157
    180158
    181 /**
    182  * Gets the current local system time.
    183  *
    184  * @returns pTime.
    185  * @param   pTime   Where to store the local time.
    186  */
     159RTDECL(int) RTTimeSet(PCRTTIMESPEC pTime)
     160{
     161    FILETIME    FileTime;
     162    SYSTEMTIME  SysTime;
     163    if (FileTimeToSystemTime(RTTimeSpecGetNtFileTime(pTime, &FileTime), &SysTime))
     164    {
     165        if (SetSystemTime(&SysTime))
     166            return VINF_SUCCESS;
     167    }
     168    return RTErrConvertFromWin32(GetLastError());
     169}
     170
     171
    187172RTDECL(PRTTIMESPEC) RTTimeLocalNow(PRTTIMESPEC pTime)
    188173{
     
    197182
    198183
    199 /**
    200  * Gets the delta between UTC and local time.
    201  *
    202  * @code
    203  *      RTTIMESPEC LocalTime;
    204  *      RTTimeSpecAddNano(RTTimeNow(&LocalTime), RTTimeLocalDeltaNano());
    205  * @endcode
    206  *
    207  * @returns Returns the nanosecond delta between UTC and local time.
    208  */
    209184RTDECL(int64_t) RTTimeLocalDeltaNano(void)
    210185{
     
    221196
    222197
    223 /**
    224  * Explodes a time spec to the localized timezone.
    225  *
    226  * @returns pTime.
    227  * @param   pTime       Where to store the exploded time.
    228  * @param   pTimeSpec   The time spec to exploded. (UTC)
    229  */
    230198RTDECL(PRTTIME) RTTimeLocalExplode(PRTTIME pTime, PCRTTIMESPEC pTimeSpec)
    231199{
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette