Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Changeset 2900

Show
Ignore:
Timestamp:
11/20/07 17:56:55 (4 years ago)
Author:
schveiguy
Message:

Updated to use new TimeSpan? struct and DateTime? for all date/time related functi
ons. THIS IS A BREAKING CHANGE.

closes #671

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/dsss.conf

    r2731 r2900  
    66    install tango/core/Memory.di $INCLUDE_PREFIX/tango/core ; \ 
    77    install tango/core/Runtime.di $INCLUDE_PREFIX/tango/core ; \ 
    8     install tango/core/Thread.di $INCLUDE_PREFIX/tango/core 
     8    install tango/core/Thread.di $INCLUDE_PREFIX/tango/core ; \ 
     9    install tango/core/TimeSpan.di $INCLUDE_PREFIX/tango/core 
    910version (GNU) { 
    1011    prebuild = $DSSS_BUILD -obj -explicit lib/common/tango/core/BitManip.d -fintfc-file=tango/core/BitManip.di ; \ 
     
    1213    $DSSS_BUILD -obj -explicit lib/common/tango/core/Memory.d -fintfc-file=tango/core/Memory.di ; \ 
    1314    $DSSS_BUILD -obj -explicit lib/common/tango/core/Runtime.d -fintfc-file=tango/core/Runtime.di ; \ 
    14     $DSSS_BUILD -obj -explicit lib/common/tango/core/Thread.d -fintfc-file=tango/core/Thread.di 
     15    $DSSS_BUILD -obj -explicit lib/common/tango/core/Thread.d -fintfc-file=tango/core/Thread.di ; \ 
     16    $DSSS_BUILD -obj -explicit lib/common/tango/core/TimeSpan.d -fintfc-file=tango/core/TimeSpan.di 
    1517} else version (DigitalMars) { 
    1618    prebuild = $DSSS_BUILD -obj -explicit lib/common/tango/core/BitManip.d -Hftango/core/BitManip.di ; \ 
     
    1820    $DSSS_BUILD -obj -explicit lib/common/tango/core/Memory.d -Hftango/core/Memory.di ; \ 
    1921    $DSSS_BUILD -obj -explicit lib/common/tango/core/Runtime.d -Hftango/core/Runtime.di ; \ 
    20     $DSSS_BUILD -obj -explicit lib/common/tango/core/Thread.d -Hftango/core/Thread.di 
     22    $DSSS_BUILD -obj -explicit lib/common/tango/core/Thread.d -Hftango/core/Thread.di ; \ 
     23    $DSSS_BUILD -obj -explicit lib/common/tango/core/TimeSpan.d -Hftango/core/TimeSpan.di 
    2124} 
    2225 
  • trunk/example/networking/selector.d

    r2525 r2900  
    103103    uint        closeCount          = 0; 
    104104    uint        errorCount          = 0; 
    105     Time        start               = Clock.now; 
     105    DateTime    start               = Clock.now; 
    106106    Thread      clientThread; 
    107107 
     
    113113    try 
    114114    { 
    115         Interval            timeout         = 1.0; // 1 sec 
     115        TimeSpan            timeout         = TimeSpan.seconds(1); 
    116116        InternetAddress     addr            = new InternetAddress(SERVER_ADDR, SERVER_PORT); 
    117117        ServerSocket        serverSocket    = new ServerSocket(addr, 5); 
     
    294294                    failedConnectCount, failedReceiveCount, failedSendCount, errorCount)); 
    295295 
    296     log.info(sprint("Total time: {0} ms", cast(uint) ((Clock.now - start) / start.TicksPerMillisecond))); 
     296    log.info(sprint("Total time: {0} ms", cast(uint) (Clock.now - start).milliseconds)); 
    297297 
    298298    clientThread.join(); 
  • trunk/example/system/localtime.d

    r2465 r2900  
    2222 
    2323        // get GMT difference in minutes 
    24         auto tz = cast(int) (WallClock.zone / Time.TicksPerMinute)
     24        auto tz = cast(int) WallClock.zone.minutes
    2525        char sign = '+'; 
    2626        if (tz < 0) 
  • trunk/lib/common/tango/core/Thread.d

    r2624 r2900  
    1515public 
    1616{ 
    17     import tango.core.Type : Interval
     17    import tango.core.TimeSpan
    1818} 
    1919private 
     
    763763     * ------------------------------------------------------------------------- 
    764764     */ 
    765     static void sleep( Interval period ) 
     765    static void sleep( TimeSpan period ) 
    766766    in 
    767767    { 
    768         assert( period * 1_000 < uint.max - 1 ); 
     768        assert( period.milliseconds < uint.max - 1 ); 
    769769    } 
    770770    body 
     
    772772        version( Win32 ) 
    773773        { 
    774             Sleep( cast(uint)( period * 1_000 ) ); 
     774            Sleep( cast(uint)( period.milliseconds ) ); 
    775775        } 
    776776        else version( Posix ) 
     
    779779            timespec tout = void; 
    780780 
    781             if( tin.tv_sec.max < period
     781            if( tin.tv_sec.max < period.seconds
    782782            { 
    783783                tin.tv_sec  = tin.tv_sec.max; 
     
    786786            else 
    787787            { 
    788                 tin.tv_sec  = cast(typeof(tin.tv_sec))  period
    789                 tin.tv_nsec = cast(typeof(tin.tv_nsec)) ((period % 1.0) * 1_000_000_000)
     788                tin.tv_sec  = cast(typeof(tin.tv_sec))  period.seconds
     789                tin.tv_nsec = cast(typeof(tin.tv_nsec)) period.nanoseconds % 1_000_000_000
    790790            } 
    791791 
     
    799799            } 
    800800        } 
     801    } 
     802 
     803    /** 
     804     * Floating point version.  The period is in terms of seconds 
     805     * 
     806     * Note: The period is not always accurate, so it is possible that the 
     807     * function would return with a timeout before the specified period.  For 
     808     * more accuracy, use the TimeSpan version. 
     809     * 
     810     */ 
     811    static void sleep( double period ) 
     812    { 
     813      sleep(TimeSpan.interval(period)); 
    801814    } 
    802815 
  • trunk/lib/common/tango/posix.mak

    r2863 r2900  
    7676    core/Runtime.o \ 
    7777    core/Thread.o \ 
    78     core/ThreadASM.o 
     78    core/ThreadASM.o \ 
     79    core/TimeSpan.o 
    7980 
    8081OBJ_STDC= \ 
     
    9697    core/Memory.html \ 
    9798    core/Runtime.html \ 
    98     core/Thread.html 
     99    core/Thread.html \ 
     100    core/TimeSpan.html 
    99101 
    100102ALL_DOCS= 
  • trunk/tango/core/sync/Condition.d

    r2809 r2900  
    1010 
    1111 
    12 public import tango.core.Type
     12public import tango.core.TimeSpan
    1313public import tango.core.Exception : SyncException; 
    1414public import tango.core.sync.Mutex; 
     
    135135     * Wait up to period seconds for a notification. 
    136136     * 
     137     * Note: The period is not always accurate, so it is possible that the 
     138     * function would return with a timeout before the specified period.  For 
     139     * more accuracy, use the TimeSpan version. 
     140     * 
    137141     * Params: 
    138142     *  period = The number of seconds to wait. 
     
    144148     *  SyncException on error. 
    145149     */ 
    146     bool wait( Interval period ) 
     150    bool wait( double period ) 
     151    { 
     152        return wait(TimeSpan.interval(period)); 
     153    } 
     154 
     155    /** 
     156     * Wait up to the specified time period for a notification. 
     157     * 
     158     * Params: 
     159     *  period = The time to wait. 
     160     * 
     161     * Returns: 
     162     *  true if notified before the timeout and false if not. 
     163     * 
     164     * Throws: 
     165     *  SyncException on error. 
     166     */ 
     167    bool wait( TimeSpan period ) 
    147168    { 
    148169        version( Win32 ) 
    149170        { 
    150             return timedWait( period < INFINITE ? 
    151                                 cast(uint)( period * 1_000 )  : INFINITE - 1 ); 
     171            return timedWait( period.milliseconds < INFINITE ? 
     172                                cast(uint)( period.milliseconds )  : INFINITE - 1 ); 
    152173        } 
    153174        else version( Posix ) 
     
    519540            { 
    520541                waiting    = true; 
    521                 alertedOne = condReady.wait( 1.0 ); 
    522                 alertedTwo = condReady.wait( 1.0 ); 
     542                alertedOne = condReady.wait( 1 ); 
     543                alertedTwo = condReady.wait( 1 ); 
    523544            } 
    524545        } 
  • trunk/tango/core/sync/Config.d

    r2809 r2900  
    1010 
    1111 
    12 public import tango.core.Type
     12public import tango.core.TimeSpan
    1313public import tango.core.Exception : SyncException; 
    1414 
     
    3838 
    3939 
    40     void adjTimespec( inout timespec t, Interval i ) 
     40    void adjTimespec( inout timespec t, TimeSpan i ) 
    4141    { 
    4242        enum 
     
    4545        } 
    4646 
    47         if( t.tv_sec.max - t.tv_sec < i
     47        if( t.tv_sec.max - t.tv_sec < i.seconds
    4848        { 
    4949            t.tv_sec  = t.tv_sec.max; 
     
    5252        else 
    5353        { 
    54             t.tv_sec  += i
    55             i = (i % 1.0) * SECS_TO_NANOS; 
    56             if( SECS_TO_NANOS - t.tv_nsec < i
     54            t.tv_sec  += i.seconds
     55            long ns = i.nanoseconds % SECS_TO_NANOS; 
     56            if( SECS_TO_NANOS - t.tv_nsec < ns
    5757            { 
    5858                t.tv_sec += 1; 
    59                 i -= SECS_TO_NANOS; 
     59                ns -= SECS_TO_NANOS; 
    6060            } 
    61             t.tv_nsec += cast(typeof(t.tv_sec)) i
     61            t.tv_nsec += cast(typeof(t.tv_sec)) ns
    6262        } 
    6363    } 
  • trunk/tango/core/sync/Semaphore.d

    r2809 r2900  
    99 
    1010 
    11 public import tango.core.Type
     11public import tango.core.TimeSpan
    1212public import tango.core.Exception : SyncException; 
    1313 
     
    126126     * Otherwise, return false. 
    127127     * 
     128     * Note: The period is not always accurate, so it is possible that the 
     129     * function would return with a timeout before the specified period.  For 
     130     * more accuracy, use the TimeSpan version. 
     131     * 
    128132     * Params: 
    129133     *  period = The number of seconds to wait. 
     
    135139     *  SyncException on error. 
    136140     */ 
    137     bool wait( Interval period ) 
    138     { 
    139         version( Win32 ) 
    140         { 
    141             DWORD t = period < INFINITE ? 
    142                         cast(uint)( period * 1_000 )  : INFINITE - 1; 
     141    bool wait( double period ) 
     142    { 
     143        return wait(TimeSpan.interval(period)); 
     144    } 
     145 
     146    /** 
     147     * Wait up to the specified time for the current count to be above zero. 
     148     * If this occurs, then atomically decrement the count by one and return 
     149     * true.  Otherwise, return false. 
     150     * 
     151     * Params: 
     152     *  period = The amount of time to wait. 
     153     * 
     154     * Returns: 
     155     *  true if notified before the timeout and false if not. 
     156     * 
     157     * Throws: 
     158     *  SyncException on error. 
     159     */ 
     160    bool wait( TimeSpan period ) 
     161    { 
     162        version( Win32 ) 
     163        { 
     164            DWORD t = period.milliseconds < INFINITE ? 
     165                        cast(uint)( period.milliseconds )  : INFINITE - 1; 
    143166            switch( WaitForSingleObject( m_hndl, t ) ) 
    144167            { 
  • trunk/tango/io/FilePath.d

    r2899 r2900  
    2323private import  tango.core.Exception; 
    2424 
    25 private import  tango.core.Type : Time; 
     25private import  tango.util.time.DateTime; 
    2626 
    2727/******************************************************************************* 
     
    813813        ***********************************************************************/ 
    814814 
    815         final Time modified () 
     815        final DateTime modified () 
    816816        { 
    817817                return timeStamps.modified; 
     
    825825        ***********************************************************************/ 
    826826 
    827         final Time accessed () 
     827        final DateTime accessed () 
    828828        { 
    829829                return timeStamps.accessed; 
     
    837837        ***********************************************************************/ 
    838838 
    839         final Time created () 
     839        final DateTime created () 
    840840        { 
    841841                return timeStamps.created; 
     
    11001100                final Stamps timeStamps () 
    11011101                { 
    1102                         static Time convert (FILETIME time) 
     1102                        static DateTime convert (FILETIME time) 
    11031103                        { 
    1104                                 return cast(Time) (Time.TicksTo1601 + *cast(ulong*) &time); 
     1104                                return DateTime.epoch1601 + TimeSpan(*cast(ulong*) &time); 
    11051105                        } 
    11061106 
     
    14181418                final Stamps timeStamps () 
    14191419                { 
    1420                         static Time convert (timeval* tv) 
     1420                        static DateTime convert (timeval* tv) 
    14211421                        { 
    1422                                 return cast(Time) (Time.TicksTo1970 + (1_000_000L * 
    1423                                                    tv.tv_sec + tv.tv_usec) * 10); 
     1422                                return DateTime.epoch1970 + 
     1423                                    TimeSpan.seconds(tv.tv_sec) + 
     1424                                    TimeSpan.microseconds(tv.tv_usec); 
    14241425                        } 
    14251426 
     
    16491650        struct Stamps 
    16501651        { 
    1651                 Time    created,        /// time created 
    1652                         accessed,       /// last time accessed 
    1653                         modified;       /// last time modified 
     1652                DateTime    created,        /// time created 
     1653                            accessed,       /// last time accessed 
     1654                            modified;       /// last time modified 
    16541655        } 
    16551656 
     
    17761777        ***********************************************************************/ 
    17771778 
    1778         abstract Time modified (); 
     1779        abstract DateTime modified (); 
    17791780 
    17801781        /*********************************************************************** 
     
    17851786        ***********************************************************************/ 
    17861787 
    1787         abstract Time accessed (); 
     1788        abstract DateTime accessed (); 
    17881789 
    17891790        /*********************************************************************** 
     
    17941795        ***********************************************************************/ 
    17951796 
    1796         abstract Time created (); 
     1797        abstract DateTime created (); 
    17971798 
    17981799        /*********************************************************************** 
  • trunk/tango/io/selector/AbstractSelector.d

    r2809 r2900  
    246246    public int select() 
    247247    { 
    248         return select(Interval.max); 
     248        return select(TimeSpan.max); 
     249    } 
     250 
     251    deprecated public int select(double timeout) 
     252    { 
     253            return select(timeout is timeout.max ? TimeSpan.max : TimeSpan.interval(timeout)); 
    249254    } 
    250255 
     
    265270     * wakeup() method has been called from another thread. 
    266271     */ 
    267     public abstract int select(Interval timeout); 
     272    public abstract int select(TimeSpan timeout); 
    268273 
    269274    /** 
     
    304309     * Cast the time duration to a C timeval struct. 
    305310    */ 
    306     public timeval* toTimeval(timeval* tv, Interval interval) 
     311    public timeval* toTimeval(timeval* tv, TimeSpan interval) 
    307312    in 
    308313    { 
     
    311316    body 
    312317    { 
    313         tv.tv_sec = cast(typeof(tv.tv_sec)) (interval)
    314         tv.tv_usec = cast(typeof(tv.tv_usec)) ((interval - tv.tv_sec) * 1_000_000); 
     318        tv.tv_sec = cast(typeof(tv.tv_sec)) interval.seconds
     319        tv.tv_usec = cast(typeof(tv.tv_usec)) (interval.microseconds % 1_000_000); 
    315320        return tv; 
    316321    } 
  • trunk/tango/io/selector/EpollSelector.d

    r2809 r2900  
    339339         * 
    340340         * Params: 
    341          * timeout  = Interval with the maximum amount of time that the 
     341         * timeout  = TimeSpan with the maximum amount of time that the 
    342342         *            selector will wait for events from the conduits; the 
    343343         *            amount of time is relative to the current system time 
     
    356356         * resources available to wait for events from the conduits. 
    357357         */ 
    358         public int select(Interval timeout) 
    359         { 
    360             int to = cast(int) (timeout != Interval.max ? cast(int) (timeout * 1000) : -1); 
     358        public int select(TimeSpan timeout) 
     359        { 
     360            int to = (timeout != TimeSpan.max ? cast(int) timeout.milliseconds : -1); 
    361361 
    362362            while (true) 
  • trunk/tango/io/selector/PollSelector.d

    r2809 r2900  
    292292         * 
    293293         * Params: 
    294          * timeout  = Interval with the maximum amount of time that the 
     294         * timeout  = Timespan with the maximum amount of time that the 
    295295         *            selector will wait for events from the conduits; the 
    296296         *            amount of time is relative to the current system time 
     
    309309         * resources available to wait for events from the conduits. 
    310310         */ 
    311         public int select(Interval timeout) 
    312         { 
    313             int to = cast(int) (timeout != Interval.max ? cast(int) (timeout * 1000) : -1); 
     311        public int select(TimeSpan timeout) 
     312        { 
     313            int to = (timeout != TimeSpan.max ? cast(int) timeout.milliseconds : -1); 
    314314 
    315315            debug (selector) 
  • trunk/tango/io/selector/SelectSelector.d

    r2873 r2900  
    411411     * 
    412412     * Params: 
    413      * timeout  = Interval with the maximum amount of time that the 
     413     * timeout  = TimeSpan with the maximum amount of time that the 
    414414     *            selector will wait for events from the conduits; the 
    415415     *            amount of time is relative to the current system time 
     
    428428     * resources available to wait for events from the conduits. 
    429429     */ 
    430     public int select(Interval timeout) 
     430    public int select(TimeSpan timeout) 
    431431    { 
    432432        fd_set *readfds; 
     
    435435        timeval tv; 
    436436 
    437         int to = cast(int) (timeout != Interval.max ? cast(int) (timeout * 1000) : -1); 
    438437 
    439438        debug (selector) 
    440             Stdout.format("--- SelectSelector.select(timeout={0} msec)\n", to); 
     439            Stdout.format("--- SelectSelector.select(timeout={0} msec)\n", timeout.milliseconds); 
    441440 
    442441        if (_readSet !is null) 
     
    472471 
    473472                // FIXME: add support for the wakeup() call. 
    474                 _eventCount = .select(_maxfd + 1, readfds, writefds, exceptfds, to is -1 ? null : &tv); 
     473                _eventCount = .select(_maxfd + 1, readfds, writefds, exceptfds, timeout is TimeSpan.max ? null : &tv); 
    475474 
    476475                debug (selector) 
     
    498497 
    499498            // FIXME: Can a system call be interrupted on Windows? 
    500             _eventCount = .select(ISelectable.Handle.max, readfds, writefds, exceptfds, to is -1 ? null : &tv); 
     499            _eventCount = .select(ISelectable.Handle.max, readfds, writefds, exceptfds, timeout is TimeSpan.max ? null : &tv); 
    501500 
    502501            debug (selector) 
  • trunk/tango/io/selector/model/ISelector.d

    r2809 r2900  
    99public import tango.io.model.IConduit; 
    1010 
    11 public import tango.core.Type : Interval
     11public import tango.core.TimeSpan
    1212 
    1313/** 
     
    400400     * 
    401401     * Params: 
    402      * timeout  = Interval with the maximum amount of time that the 
     402     * timeout  = TimeSpan with the maximum amount of time that the 
    403403     *            selector will wait for events from the conduits; the 
    404404     *            amount of time is relative to the current system time 
     
    410410     * have received events within the specified timeout. 
    411411     */ 
    412     public abstract int select(Interval timeout); 
     412    public abstract int select(TimeSpan timeout); 
     413 
     414    /* 
     415     * Deprecated: use select(TimeSpan) instead 
     416     * 
     417     * Params: 
     418     * timeout  = the maximum amount of time in seconds that the 
     419     *            selector will wait for events from the conduits; the 
     420     *            amount of time is relative to the current system time 
     421     *            (i.e. just the number of milliseconds that the selector 
     422     *            has to wait for the events). 
     423     * 
     424     * Returns: 
     425     * The amount of conduits that have received events; 0 if no conduits 
     426     * have received events within the specified timeout. 
     427     */ 
     428    deprecated public abstract int select(double timeout); 
    413429 
    414430    /** 
  • trunk/tango/net/Socket.d

    r2588 r2900  
    6767private import  tango.core.Exception; 
    6868 
    69 private import  tango.core.Type : Interval
     69private import  tango.core.TimeSpan
    7070 
    7171 
     
    13591359        ***********************************************************************/ 
    13601360 
    1361         static int select (SocketSet checkRead, SocketSet checkWrite, SocketSet checkError, Interval time) 
     1361        static int select (SocketSet checkRead, SocketSet checkWrite, SocketSet checkError, TimeSpan time) 
    13621362        { 
    13631363                auto tv = toTimeval (time); 
     
    13651365        } 
    13661366 
     1367        /*********************************************************************** 
     1368                select with specified timeout 
     1369           
     1370                Note: The period is not always accurate, so it is possible 
     1371                that the function will return with a timeout before the 
     1372                specified period.  For more accuracy, use the TimeSpan 
     1373                version. 
     1374        ***********************************************************************/ 
     1375 
     1376        static int select (SocketSet checkRead, SocketSet checkWrite, SocketSet checkError, double time) 
     1377        { 
     1378                return select(checkRead, checkWrite, checkError, TimeSpan.interval(time)); 
     1379        } 
     1380 
    13671381 
    13681382        /*********************************************************************** 
     
    13791393        /*********************************************************************** 
    13801394 
    1381                 Handy utility for converting Time into timeval 
    1382  
    1383         ***********************************************************************/ 
    1384  
    1385         static timeval toTimeval (Interval time) 
     1395                Handy utility for converting TimeSpan into timeval 
     1396 
     1397        ***********************************************************************/ 
     1398 
     1399        static timeval toTimeval (TimeSpan time) 
    13861400        { 
    13871401                timeval tv; 
    1388                 tv.tv_sec = cast(uint) time
    1389                 tv.tv_usec = cast(uint) ((time - tv.tv_sec) * 1_000_000.0)
     1402                tv.tv_sec = cast(uint) time.seconds
     1403                tv.tv_usec = cast(uint) time.microseconds % 1_000_000
    13901404                return tv; 
    13911405        } 
  • trunk/tango/net/SocketConduit.d

    r2739 r2900  
    1919private import  tango.net.Socket; 
    2020 
    21 private import  tango.core.Type : Interval
     21private import  tango.core.TimeSpan
    2222 
    2323/******************************************************************************* 
     
    121121        ***********************************************************************/ 
    122122 
    123         SocketConduit setTimeout (Interval interval) 
     123        SocketConduit setTimeout (TimeSpan interval) 
    124124        { 
    125125                tv = socket_.toTimeval (interval); 
    126126                return this; 
     127        } 
     128 
     129        deprecated SocketConduit setTimeout (double interval) 
     130        { 
     131                return setTimeout(TimeSpan.interval(interval)); 
    127132        } 
    128133 
  • trunk/tango/net/cluster/CacheInvalidator.d

    r2809 r2900  
    6464        ***********************************************************************/ 
    6565         
    66         void invalidate (char[] key, Time timeLimit = Time.max) 
     66        void invalidate (char[] key, DateTime timeLimit = DateTime.max) 
    6767        { 
    6868                assert (key.length); 
  • trunk/tango/net/cluster/NetworkClient.d

    r2878 r2900  
    9393        ***********************************************************************/ 
    9494         
    95         Time time () 
     95        DateTime time () 
    9696        { 
    9797                return Clock.now; 
  • trunk/tango/net/cluster/NetworkMessage.d

    r2878 r2900  
    4343class NetworkMessage : IMessage 
    4444{ 
    45         private uint    id_; 
    46         private long    time_; 
    47         private char[]  reply_; 
     45        private uint      id_; 
     46        private DateTime  time_; 
     47        private char[]    reply_; 
    4848 
    4949        /*********************************************************************** 
     
    9898        ***********************************************************************/ 
    9999 
    100         void time (Time time) 
     100        void time (DateTime time) 
    101101        { 
    102102                time_ = time; 
     
    109109        ***********************************************************************/ 
    110110 
    111         Time time () 
     111        DateTime time () 
    112112        { 
    113                 return cast(Time) time_; 
     113                return time_; 
    114114        } 
    115115 
     
    140140        void read (IReader input) 
    141141        {        
    142                 input (id_) (time_) (reply_); 
     142                input (id_) (time_.ticks) (reply_); 
    143143        } 
    144144 
     
    151151        void write (IWriter output) 
    152152        { 
    153                 output (id_) (time_) (reply_); 
     153                output (id_) (time_.ticks) (reply_); 
    154154        } 
    155155 
  • trunk/tango/net/cluster/QueuedCache.d

    r2809 r2900  
    1313module tango.net.cluster.QueuedCache; 
    1414 
    15 private import tango.core.Type : Time; 
     15private import tango.util.time.DateTime; 
    1616 
    1717private import tango.net.cluster.model.ICache; 
     
    116116        **********************************************************************/ 
    117117 
    118         synchronized bool put (K key, V value, Time time = Time.init) 
     118        synchronized bool put (K key, V value, DateTime time = DateTime.init) 
    119119        { 
    120120                assert (key !is key.init); 
     
    138138        **********************************************************************/ 
    139139 
    140         synchronized bool put (K peek, K delegate() key, V delegate() value, Time time = Time.init) 
     140        synchronized bool put (K peek, K delegate() key, V delegate() value, DateTime time = DateTime.init) 
    141141        { 
    142142                assert (peek !is peek.init); 
     
    162162        **********************************************************************/ 
    163163 
    164         synchronized V remove (K key, Time time = Time.max) 
     164        synchronized V remove (K key, DateTime time = DateTime.max) 
    165165        { 
    166166                auto e = lookup (key); 
     
    171171                   // don't actually kill the list entry -- just place 
    172172                   // it at the list 'tail' ready for subsequent reuse 
    173                    deReference(e).set (K.init, V.init, Time.min); 
     173                   deReference(e).set (K.init, V.init, DateTime.min); 
    174174 
    175175                   map.remove (key); 
     
    288288                QueuedEntry*    prev, 
    289289                                next; 
    290                 Time            time; 
     290                DateTime        time; 
    291291                V               value; 
    292292 
     
    297297                **************************************************************/ 
    298298 
    299                 QueuedEntry* set (K key, V value, Time time) 
     299                QueuedEntry* set (K key, V value, DateTime time) 
    300300                { 
    301301                        this.value = value; 
  • trunk/tango/net/cluster/model/ICache.d

    r2809 r2900  
    1111module tango.net.cluster.model.ICache; 
    1212 
    13 private import tango.core.Type : Time; 
     13private import tango.util.time.DateTime; 
    1414 
    1515/****************************************************************************** 
     
    3838        **********************************************************************/ 
    3939 
    40         bool put (K key, V entry, Time time = Time.init); 
     40        bool put (K key, V entry, DateTime time = DateTime.init); 
    4141 
    4242        /********************************************************************** 
     
    5050        **********************************************************************/ 
    5151 
    52         V remove (K key, Time time = Time.max); 
     52        V remove (K key, DateTime time = DateTime.max); 
    5353} 
    5454 
  • trunk/tango/net/cluster/model/IMessage.d

    r2809 r2900  
    1313module tango.net.cluster.model.IMessage; 
    1414 
    15 public import tango.core.Type : Time; 
     15public import tango.util.time.DateTime; 
    1616 
    1717public import tango.io.protocol.model.IReader, 
     
    5252        ***********************************************************************/ 
    5353         
    54         void time (Time value); 
     54        void time (DateTime value); 
    5555 
    5656        /*********************************************************************** 
     
    5858        ***********************************************************************/ 
    5959         
    60         Time time (); 
     60        DateTime time (); 
    6161 
    6262        /*********************************************************************** 
  • trunk/tango/net/cluster/tina/CacheThread.d

    r2809 r2900  
    7373                                 
    7474                            // return the content if we can't put it in the cache 
    75                             if (cache.put (channel, element, content, cast(Time) time)) 
     75                            if (cache.put (channel, element, content, DateTime(time))) 
    7676                                writer.success ("success");  
    7777                            else 
  • trunk/tango/net/cluster/tina/Cluster.d

    r2809 r2900  
    987987        abstract bool reset(); 
    988988 
    989         abstract void done (Time time); 
     989        abstract void done (DateTime time); 
    990990 
    991991        abstract SocketConduit conduit (); 
     
    10091009        private InternetAddress address; 
    10101010        private PoolConnection  freelist; 
    1011         private Time            timeout = cast(Time) (60 * Time.TicksPerSecond); 
     1011        private TimeSpan        timeout = TimeSpan.seconds(60); 
    10121012 
    10131013        /*********************************************************************** 
     
    10201020        static class PoolConnection : Connection 
    10211021        { 
    1022                 Time            time; 
     1022                DateTime        time; 
    10231023                PoolConnection  next;    
    10241024                ConnectionPool  parent;    
     
    10551055 
    10561056                            // set a 500ms timeout for read operations 
    1057                             conduit_.setTimeout (0.500); 
     1057                            conduit_.setTimeout (TimeSpan.milliseconds(500)); 
    10581058 
    10591059                            // open a connection to this server 
     
    11001100                ***************************************************************/ 
    11011101 
    1102                 final void done (Time time) 
     1102                final void done (DateTime time) 
    11031103                { 
    11041104                        synchronized (parent) 
     
    11321132        ***********************************************************************/ 
    11331133 
    1134         final synchronized Connection borrow (Time time) 
     1134        final synchronized Connection borrow (DateTime time) 
    11351135        {   
    11361136                if (freelist) 
     
    12931293        {        
    12941294                ProtocolWriter.Command  cmd; 
    1295                 Time                    time; 
     1295                DateTime                time; 
    12961296                char[]                  channel; 
    12971297                char[]                  element; 
  • trunk/tango/net/cluster/tina/ClusterCache.d

    r2878 r2900  
    6464        **********************************************************************/ 
    6565 
    66         bool put (char[] channel, char[] element, ClusterContent content, Time time) 
     66        bool put (char[] channel, char[] element, ClusterContent content, DateTime time) 
    6767        {        
    6868                return lookup(channel).put (element, {return element.dup;},  
     
    102102        **********************************************************************/ 
    103103 
    104         bool lock (char[] channel, char[] element, Time time) 
     104        bool lock (char[] channel, char[] element, DateTime time) 
    105105        { 
    106106                return true; 
  • trunk/tango/net/cluster/tina/ClusterQueue.d

    r2809 r2900  
    3030        private uint            used,  
    3131                                limit; 
    32         private Interval        sleep; 
     32        private TimeSpan        sleep; 
    3333        private Thread          thread; 
    3434        private Cluster         cluster; 
     
    5656        **********************************************************************/ 
    5757 
    58         this (Cluster cluster, uint limit, Interval sleep) 
     58        this (Cluster cluster, uint limit, TimeSpan sleep) 
    5959        { 
    6060                thread = new Thread (&run); 
     
    112112        **********************************************************************/ 
    113113 
    114         this (Cluster cluster, uint limit, Interval sleep) 
     114        this (Cluster cluster, uint limit, TimeSpan sleep) 
    115115        { 
    116116                super (cluster, limit, sleep); 
  • trunk/tango/net/cluster/tina/ClusterServer.d

    r2809 r2900  
    119119                      getLogger.trace ("heartbeat"); 
    120120                      channel.broadcast (rollcall); 
    121                       Thread.sleep (30.0); 
     121                      Thread.sleep (TimeSpan.seconds(30)); 
    122122                      } 
    123123        } 
  • trunk/tango/net/cluster/tina/ProtocolWriter.d

    r2809 r2900  
    100100        ProtocolWriter put (Command cmd, char[] channel, char[] element = null, IMessage msg = null) 
    101101        { 
    102                 auto time = (msg ? msg.time : Time.init); 
     102                auto time = (msg ? msg.time : DateTime.init); 
    103103         
    104104                // reset the buffer first! 
     
    109109                     (cast(ubyte) cmd) 
    110110                     (cast(ubyte) Version) 
    111                      (cast(ulong) time
     111                     (cast(ulong) time.ticks
    112112                     (channel) 
    113113                     (element); 
     
    141141                     (cast(ubyte) ProtocolWriter.Command.OK) 
    142142                     (cast(ubyte) Version) 
    143                      (cast(ulong) Time.init); 
     143                     (cast(ulong) ulong.init); 
    144144 
    145145                // and the payload (which includes both channel & element) 
  • trunk/tango/net/cluster/tina/QueueServer.d

    r2809 r2900  
    1717                tango.net.cluster.tina.ClusterQueue,   
    1818                tango.net.cluster.tina.ClusterServer; 
     19 
     20private import  tango.core.TimeSpan; 
    1921 
    2022/****************************************************************************** 
     
    4143                // create a queue instance 
    4244                // queue = new MemoryQueue  (cluster, 64 * 1024 * 1024, 1.0); 
    43                 queue = new PersistQueue (cluster, 64 * 1024 * 1024, 3.0); 
     45                queue = new PersistQueue (cluster, 64 * 1024 * 1024, TimeSpan.seconds(3)); 
    4446 
    4547        } 
  • trunk/tango/net/ftp/FtpClient.d

    r2809 r2900  
    3131private import  Timestamp = tango.text.convert.TimeStamp; 
    3232 
     33private import  tango.core.TimeSpan; 
    3334 
    3435/// An FTP progress delegate. 
     
    141142    long size = -1; 
    142143    /// Modification time, if available. 
    143     Time modify = Time.max; 
     144    DateTime modify = DateTime.max; 
    144145    /// Creation time, if available (not often.) 
    145     Time create = Time.max; 
     146    DateTime create = DateTime.max; 
    146147    /// The file's mime type, if known. 
    147148    char[] mime = null; 
     
    616617 
    617618                // At end_time, we bail. 
    618                 Time end_time = cast(Time) (Clock.now + this.timeout)
     619                DateTime end_time = Clock.now + this.timeout
    619620 
    620621                while (Clock.now < end_time) 
     
    624625 
    625626                        // Can we accept yet? 
    626                         int code = Socket.select(set, null, null, this.timeout/Time.TicksPerSecond); 
     627                        int code = Socket.select(set, null, null, this.timeout); 
    627628                        if (code == -1 || code == 0) 
    628629                            break; 
     
    12241225 
    12251226                if (Timestamp.dostime (r.match(0), info.modify) is 0) 
    1226                     info.modify = Time.max; 
     1227                    info.modify = DateTime.max; 
    12271228 
    12281229                pos = r.match(0).length; 
     
    13441345    /// 
    13451346    /// Returns:             a d_time representing the same date 
    1346     protected Time parseTimeval(char[] timeval) 
     1347    protected DateTime parseTimeval(char[] timeval) 
    13471348    { 
    13481349        Date date; 
     
    13681369    /// 
    13691370    /// Returns:             a d_time representing the mtime 
    1370     public Time filemtime(char[] path) 
     1371    public DateTime filemtime(char[] path) 
    13711372        in 
    13721373    { 
     
    15441545 
    15451546        // At end_time, we bail. 
    1546         Time end_time = cast(Time) (Clock.now + this.timeout)
     1547        DateTime end_time = Clock.now + this.timeout
    15471548 
    15481549        // This is the buffer the stream data is stored in. 
     
    15591560 
    15601561                // Can we write yet, can we write yet? 
    1561                 int code = Socket.select(null, set, null, this.timeout/Time.TicksPerSecond); 
     1562                int code = Socket.select(null, set, null, this.timeout); 
    15621563                if (code == -1 || code == 0) 
    15631564                    break; 
     
    15831584                // Give it more time as long as data is going through. 
    15841585                if (delta != 0) 
    1585                     end_time = cast(Time) (Clock.now + this.timeout)
     1586                    end_time = Clock.now + this.timeout
    15861587            } 
    15871588 
     
    16111612 
    16121613        // At end_time, we bail. 
    1613         Time end_time = cast(Time) (Clock.now + this.timeout)
     1614        DateTime end_time = Clock.now + this.timeout
    16141615 
    16151616        // This is the buffer the stream data is stored in. 
     
    16251626 
    16261627                // Can we read yet, can we read yet? 
    1627                 int code = Socket.select(set, null, null, this.timeout/Time.TicksPerSecond); 
     1628                int code = Socket.select(set, null, null, this.timeout); 
    16281629                if (code == -1 || code == 0) 
    16291630                    break; 
     
    16461647 
    16471648                // Give it more time as long as data is going through. 
    1648                 end_time = cast(Time) (Clock.now + this.timeout)
     1649                end_time = Clock.now + this.timeout
    16491650            } 
    16501651 
     
    17551756 
    17561757        // Pick a time at which we stop reading.  It can't take too long, but it could take a bit for the whole response. 
    1757         Time end_time = cast(Time) (Clock.now + this.timeout * 10)
     1758        DateTime end_time = Clock.now + this.timeout * 10
    17581759 
    17591760        FtpResponse response; 
  • trunk/tango/net/ftp/Telnet.d

    r2809 r2900  
    2020 
    2121private import Integer = tango.text.convert.Integer; 
     22 
     23private import tango.core.TimeSpan; 
    2224 
    2325 
     
    3436 
    3537        /// The number of milliseconds to wait for socket communication or connection. 
    36         protected Time timeout = cast(Time) (5000 * Time.TicksPerMillisecond); 
     38        protected TimeSpan timeout = TimeSpan.milliseconds(5000); 
    3739 
    3840        /// provided by host 
     
    6264        { 
    6365                // At end_time, we bail. 
    64                 Time end_time = cast(Time) (Clock.now + this.timeout)
     66                DateTime end_time = Clock.now + this.timeout
    6567 
    6668                // Set up a SocketSet so we can use select() - it's pretty efficient. 
     
    7678 
    7779                        // Can we write yet, can we write yet? 
    78                         int code = Socket.select(null, set, null, this.timeout / Time.TicksPerSecond); 
     80                        int code = Socket.select(null, set, null, this.timeout); 
    7981                        if (code == -1 || code == 0) 
    8082                                break; 
     
    101103        { 
    102104                // Figure, first, how long we're allowed to take. 
    103                 Time end_time = cast(Time) (Clock.now + this.timeout)
     105                DateTime end_time = Clock.now + this.timeout
    104106 
    105107                // An overall buffer and a one-char buffer. 
     
    135137 
    136138                        // Try to read from the socket. 
    137                         int code = Socket.select(set, null, null, this.timeout / Time.TicksPerSecond); 
     139                        int code = Socket.select(set, null, null, this.timeout); 
    138140                        if (code == -1 || code == 0) 
    139141                                break; 
     
    210212 
    211213                        // Anyone available? 
    212                         int code = Socket.select(null, set, null, this.timeout / Time.TicksPerSecond); 
     214                        int code = Socket.select(null, set, null, this.timeout); 
    213215                        if (code == -1 || code == 0) 
    214216                                break; 
     
    237239                   { 
    238240                   char[10] tmp; 
    239                    exception ("CLIENT: Unable to connect within the specified time limit (" ~ Integer.itoa(tmp, cast(uint) (this.timeout/Time.TicksPerMillisecond)) ~ " ms.)"); 
     241                   exception ("CLIENT: Unable to connect within the specified time limit (" ~ Integer.itoa(tmp, cast(uint) this.timeout.milliseconds) ~ " ms.)"); 
    240242                   } 
    241243 
  • trunk/tango/net/http/HttpClient.d

    r2738 r2900  
    2525                tango.net.InternetAddress; 
    2626 
    27 private import  tango.core.Type : Interval
     27private import  tango.core.TimeSpan
    2828                 
    2929private import  tango.net.http.HttpConst, 
     
    104104 
    105105        // default to three second timeout on read operations ... 
    106         private Interval                timeout = 3
     106        private TimeSpan                timeout = TimeSpan.seconds(3)
    107107 
    108108        // should we perform internal redirection? 
     
    305305        ***********************************************************************/ 
    306306 
    307         void setTimeout (Interval interval) 
     307        void setTimeout (TimeSpan interval) 
    308308        { 
    309309                timeout = interval; 
     310        } 
     311 
     312        /** 
     313         * Deprecated: use setTimeout(TimeSpan) instead 
     314         */ 
     315        deprecated void setTimeout(double interval) 
     316        { 
     317                setTimeout(TimeSpan.interval(interval)); 
    310318        } 
    311319 
  • trunk/tango/net/http/HttpHeaders.d

    r2023 r2900  
    2121private import  tango.text.stream.LineIterator; 
    2222 
     23private import  tango.util.time.DateTime; 
     24 
    2325/****************************************************************************** 
    2426 
     
    128130        /********************************************************************** 
    129131                 
    130                 Return the date value of the provided header, or Time.max  
     132                Return the date value of the provided header, or DateTime.max  
    131133                if the header does not exist 
    132134 
    133135        **********************************************************************/ 
    134136 
    135         Time getDate (HttpHeaderName name, Time def = Time.max) 
     137        DateTime getDate (HttpHeaderName name, DateTime def = DateTime.max) 
    136138        { 
    137139                return super.getDate (name.value, def); 
     
    309311        **********************************************************************/ 
    310312 
    311         void addDate (HttpHeaderName name, Time value) 
     313        void addDate (HttpHeaderName name, DateTime value) 
    312314        { 
    313315                super.addDate (name.value, value); 
  • trunk/tango/net/http/HttpParams.d

    r2281 r2900  
    2020 
    2121private import  tango.text.stream.SimpleIterator; 
     22 
     23private import  tango.util.time.DateTime; 
    2224 
    2325public  import  tango.net.http.model.HttpParamsView; 
     
    115117        **********************************************************************/ 
    116118 
    117         void addDate (char[] name, Time value) 
     119        void addDate (char[] name, DateTime value) 
    118120        { 
    119121                super.addDate (name, value); 
     
    151153        **********************************************************************/ 
    152154 
    153         Time getDate (char[] name, Time ret = Time.max) 
     155        DateTime getDate (char[] name, DateTime ret = DateTime.max) 
    154156        { 
    155157                return super.getDate (name, ret); 
  • trunk/tango/net/http/HttpTokens.d

    r2281 r2900  
    2222private import  Text = tango.text.Util; 
    2323 
    24 private import  tango.core.Type : Time; 
     24private import  tango.util.time.DateTime; 
    2525 
    2626private import  tango.io.protocol.model.IWriter; 
     
    217217        **********************************************************************/ 
    218218 
    219         Time getDate (char[] name, Time date = Time.max) 
     219        DateTime getDate (char[] name, DateTime date = DateTime.max) 
    220220        { 
    221221                char[] value = get (name); 
     
    534534        **********************************************************************/ 
    535535 
    536         protected void addDate (char[] name, Time value) 
     536        protected void addDate (char[] name, DateTime value) 
    537537        { 
    538538                char[40] tmp = void; 
  • trunk/tango/net/http/model/HttpParamsView.d

    r2809 r2900  
    1313module tango.net.http.model.HttpParamsView; 
    1414 
    15 private import  tango.core.Type : Time; 
     15private import  tango.util.time.DateTime; 
    1616 
    1717private import  tango.io.model.IBuffer; 
     
    5959        **********************************************************************/ 
    6060 
    61         Time getDate (char[] name, Time ret = Time.max); 
     61        DateTime getDate (char[] name, DateTime ret = DateTime.max); 
    6262 
    6363        /********************************************************************** 
  • trunk/tango/text/convert/TimeStamp.d

    r2809 r2900  
    6565******************************************************************************/ 
    6666 
    67 char[] toUtf8 (Time time) 
     67char[] toUtf8 (DateTime time) 
    6868{ 
    6969        char[32] tmp = void; 
     
    8181******************************************************************************/ 
    8282 
    83 wchar[] toUtf16 (Time time) 
     83wchar[] toUtf16 (DateTime time) 
    8484{ 
    8585        wchar[32] tmp = void; 
     
    9797******************************************************************************/ 
    9898 
    99 dchar[] toUtf32 (Time time) 
     99dchar[] toUtf32 (DateTime time) 
    100100{ 
    101101        dchar[32] tmp = void; 
     
    117117******************************************************************************/ 
    118118 
    119 T[] format(T, U=Time) (T[] output, U time) 
    120 {return format!(T)(output, cast(Time) time);} 
    121  
    122 T[] format(T) (T[] output, Time time) 
     119T[] format(T, U=DateTime) (T[] output, U time) 
     120{return format!(T)(output, cast(DateTime) time);} 
     121 
     122T[] format(T) (T[] output, DateTime time) 
    123123{ 
    124124        // these arrays also reside in Date, but need to be templated here 
     
    138138 
    139139        if (time is time.max) 
    140             throw new IllegalArgumentException ("TimeStamp.format :: invalid Time argument"); 
     140            throw new IllegalArgumentException ("TimeStamp.format :: invalid DateTime argument"); 
    141141 
    142142        // convert time to field values 
     
    160160 
    161161      Parse provided input and return a UTC epoch time. A return value  
    162       of Time.max indicated a parse-failure. 
     162      of DateTime.max indicated a parse-failure. 
    163163 
    164164      An option is provided to return the count of characters parsed -  
     
    167167******************************************************************************/ 
    168168 
    169 Time parse(T) (T[] src, uint* ate = null) 
     169DateTime parse(T) (T[] src, uint* ate = null) 
    170170{ 
    171171        int     len; 
    172         Time    value; 
     172        DateTime    value; 
    173173 
    174174        if ((len = rfc1123 (src, value)) > 0 ||  
     
    181181           } 
    182182 
    183         return Time.max; 
     183        return DateTime.max; 
    184184} 
    185185 
     
    194194******************************************************************************/ 
    195195 
    196 int rfc1123(T) (T[] src, inout Time value) 
     196int rfc1123(T) (T[] src, inout DateTime value) 
    197197{ 
    198198        Date    date; 
     
    234234******************************************************************************/ 
    235235 
    236 int rfc850(T) (T[] src, inout Time value) 
     236int rfc850(T) (T[] src, inout DateTime value) 
    237237{ 
    238238        Date    date; 
     
    280280******************************************************************************/ 
    281281 
    282 int asctime(T) (T[] src, inout Time value) 
     282int asctime(T) (T[] src, inout DateTime value) 
    283283{ 
    284284        Date    date; 
     
    318318******************************************************************************/ 
    319319 
    320 int dostime(T) (T[] src, inout Time value) 
     320int dostime(T) (T[] src, inout DateTime value) 
    321321{ 
    322322        Date    date; 
     
    364364******************************************************************************/ 
    365365 
    366 int iso8601(T) (T[] src, inout Time value) 
     366int iso8601(T) (T[] src, inout DateTime value) 
    367367{ 
    368368        Date    date; 
  • trunk/tango/text/locale/Convert.d

    r2878 r2900  
    414414else 
    415415{ 
    416                                   auto minutes = cast(int) (WallClock.zone / Time.TicksPerMinute); 
     416                                  auto minutes = cast(int) (WallClock.zone.minutes); 
    417417                                  if (minutes < 0) 
    418418                                      minutes = -minutes, result ~= '-'; 
  • trunk/tango/util/log/Event.d

    r2878 r2900  
    5050        private char[]          msg, 
    5151                                name; 
    52         private Time            time; 
     52        private DateTime        time; 
    5353        private Level           level; 
    5454        private IHierarchy      hierarchy; 
    5555 
    5656        // timestamps 
    57         private static Time    beginTime; 
     57        private static DateTime beginTime; 
    5858 
    5959        // scratch buffer for constructing output strings 
     
    153153                         
    154154                        QueryPerformanceCounter (&timerStart); 
    155                         multiplier = 10_000_000.0 / freq;        
     155                        multiplier = cast(double)TimeSpan.second.ticks / freq;        
    156156                        beginTime = Clock.now; 
    157157 
     
    165165        ***********************************************************************/ 
    166166 
    167         final static Time startedAt () 
     167        final static DateTime startedAt () 
    168168        { 
    169169                return beginTime; 
     
    176176        ***********************************************************************/ 
    177177 
    178         final static Time timer () 
     178        final static DateTime timer () 
    179179        { 
    180180                version (Posix)        
     
    188188 
    189189                        QueryPerformanceCounter (&now); 
    190                         return cast(Time) ((now - timerStart) * multiplier + beginTime); 
     190                        return beginTime + TimeSpan(cast(long)((now - timerStart) * multiplier)); 
    191191                } 
    192192        } 
     
    299299        ***********************************************************************/ 
    300300 
    301         final Time getTime () 
    302         { 
    303                 return cast(Time) (time - beginTime)
     301        final TimeSpan getTime () 
     302        { 
     303                return time - beginTime
    304304        } 
    305305 
     
    310310        ***********************************************************************/ 
    311311 
    312         final Time getEpochTime () 
     312        final DateTime getEpochTime () 
    313313        { 
    314314                return time; 
  • trunk/tango/util/log/EventLayout.d

    r2809 r2900  
    1515private import tango.util.log.Event; 
    1616 
    17 private import tango.core.Type : Time; 
     17private import tango.core.TimeSpan; 
     18 
     19private import tango.util.time.DateTime; 
    1820 
    1921/******************************************************************************* 
     
    6466        ***********************************************************************/ 
    6567 
    66         final char[] toMilli (char[] s, Time time) 
     68        final char[] toMilli (char[] s, TimeSpan time) 
    6769        { 
    6870                assert (s.length > 0); 
    69                 time /= time.TicksPerMillisecond
     71                long ms = time.milliseconds
    7072 
    7173                int len = s.length; 
    7274                do { 
    73                    s[--len] = time % 10 + '0'; 
    74                    time /= 10; 
    75                    } while (time && len); 
     75                   s[--len] = ms % 10 + '0'; 
     76                   ms /= 10; 
     77                   } while (ms && len); 
    7678                return s[len..s.length];                 
     79        } 
     80 
     81        final char[] toMilli (char[] s, DateTime time) 
     82        { 
     83                return toMilli(s, TimeSpan(time.ticks)); 
    7784        } 
    7885} 
  • trunk/tango/util/log/Hierarchy.d

    r2878 r2900  
    2222 
    2323private import  tango.util.log.model.IHierarchy; 
     24 
     25private import  tango.util.time.Clock; 
    2426 
    2527/******************************************************************************* 
     
    344346        /*********************************************************************** 
    345347         
    346                 Get number of milliseconds since this application started 
    347  
    348         ***********************************************************************/ 
    349  
    350         final Time runtime () 
    351         { 
    352                 return Event.startedAt; 
     348                Get time since this application started 
     349 
     350        ***********************************************************************/ 
     351 
     352        final TimeSpan runtime () 
     353        { 
     354                return Clock.now - Event.startedAt; 
    353355        } 
    354356 
  • trunk/tango/util/log/Logger.d

    r2809 r2900  
    1717 
    1818private import tango.util.log.model.ILevel; 
     19 
     20private import tango.core.TimeSpan; 
    1921 
    2022/******************************************************************************* 
     
    249251        ***********************************************************************/ 
    250252 
    251         abstract Time runtime (); 
     253        abstract TimeSpan runtime (); 
    252254} 
  • trunk/tango/util/log/RollingFileAppender.d

    r2809 r2900  
    2121private import  tango.util.log.Appender, 
    2222                tango.util.log.FileAppender; 
     23 
     24private import  tango.util.time.DateTime; 
    2325 
    2426/******************************************************************************* 
     
    5658 
    5759                char[1] x; 
    58                 Time mostRecent; 
     60                DateTime mostRecent; 
    5961 
    6062                for (int i=0; i < count; ++i) 
  • trunk/tango/util/time/Clock.d

    r2809 r2900  
    1919private import  tango.core.Exception; 
    2020 
    21 public  import  tango.core.Type : Time; 
     21public  import  tango.core.TimeSpan; 
     22 
     23public  import  tango.util.time.DateTime; 
    2224 
    2325/****************************************************************************** 
     
    2527        Exposes UTC time relative to Jan 1st, 1 AD. These values are 
    2628        based upon a clock-tick of 100ns, giving them a span of greater 
    27         than 10,000 years. Units of Time are the foundation of most time 
    28         and date functionality in Tango. 
     29        than 10,000 years. These units of time are the foundation of most 
     30        time and date functionality in Tango. 
    2931 
    3032        Interval is another type of time period, used for measuring a 
     
    4547                ***************************************************************/ 
    4648 
    47                 static Time now () 
     49                static DateTime now () 
    4850                { 
    4951                        FILETIME fTime = void; 
     
    6769                        Set fields to represent the provided UTC time. Note  
    6870                        that the conversion is limited by the underlying OS, 
    69                         and will fail to operate correctly with Time values  
    70                         beyond the domain. On Win32 the earliest representable  
    71                         date is 1601. On linux it is 1970. Both systems have  
    72                         limitations upon future dates also. Date is limited  
    73                         to millisecond accuracy at best. 
    74  
    75                 ***************************************************************/ 
    76  
    77                 static Date toDate (Time time) 
     71                        and will fail to operate correctly with DateTime 
     72                        values beyond the domain. On Win32 the earliest 
     73                        representable date is 1601. On linux it is 1970. Both 
     74                        systems have limitations upon future dates also. Date 
     75                        is limited to millisecond accuracy at best. 
     76 
     77                ***************************************************************/ 
     78 
     79                static Date toDate (DateTime time) 
    7880                { 
    7981                        Date date = void; 
     
    9698                /*************************************************************** 
    9799 
    98                         Convert Date fields to Time 
     100                        Convert Date fields to DateTime 
    99101 
    100102                        Note that the conversion is limited by the underlying  
    101                         OS, and will not operate correctly with Time values  
    102                         beyond the domain. On Win32 the earliest representable  
    103                         date is 1601. On linux it is 1970. Both systems have  
    104                         limitations upon future dates also. Date is limited  
    105                         to millisecond accuracy at best. 
    106  
    107                 ***************************************************************/ 
    108  
    109                 static Time fromDate (inout Date date) 
     103                        OS, and will not operate correctly with DateTime 
     104                        values beyond the domain. On Win32 the earliest 
     105                        representable date is 1601. On linux it is 1970. Both 
     106                        systems have limitations upon future dates also. Date 
     107                        is limited to millisecond accuracy at best. 
     108 
     109                ***************************************************************/ 
     110 
     111                static DateTime fromDate (inout Date date) 
    110112                { 
    111113                        SYSTEMTIME sTime = void; 
     
    127129                /*************************************************************** 
    128130 
    129                         Convert FILETIME to a Time 
    130  
    131                 ***************************************************************/ 
    132  
    133                 package static Time convert (FILETIME time) 
    134                 { 
    135                         return cast(Time) (Time.TicksTo1601 + *cast(ulong*) &time); 
    136                 } 
    137  
    138                 /*************************************************************** 
    139  
    140                         Convert Time to a FILETIME 
    141  
    142                 ***************************************************************/ 
    143  
    144                 package static FILETIME convert (Time span) 
     131                        Convert FILETIME to a DateTime 
     132 
     133                ***************************************************************/ 
     134 
     135                package static DateTime convert (FILETIME time) 
     136                { 
     137                        ulong t = *cast(ulong*)&time; 
     138                        t *= 100 / TimeSpan.NanosecondsPerTick; 
     139                        return DateTime.epoch1601 + TimeSpan(t); 
     140                } 
     141 
     142                /*************************************************************** 
     143 
     144                        Convert DateTime to a FILETIME 
     145 
     146                ***************************************************************/ 
     147 
     148                package static FILETIME convert (DateTime dt) 
    145149                { 
    146150                        FILETIME time = void; 
    147151 
    148                         span -= span.TicksTo1601; 
    149                         assert (span >= 0); 
    150                         *cast(long*) &time.dwLowDateTime = span
     152                        TimeSpan span = dt - DateTime.epoch1601; 
     153                        assert (span >= TimeSpan.zero); 
     154                        *cast(long*) &time.dwLowDateTime = span.ticks
    151155                        return time; 
    152156                } 
     
    161165                ***************************************************************/ 
    162166 
    163                 static Time now () 
     167                static DateTime now () 
    164168                { 
    165169                        timeval tv = void; 
    166170                        if (gettimeofday (&tv, null)) 
    167                             throw new PlatformException ("Time.utc :: Posix timer is not available"); 
     171                            throw new PlatformException ("Clock.now :: Posix timer is not available"); 
    168172 
    169173                        return convert (tv); 
     
    185189                        Set fields to represent the provided UTC time. Note  
    186190                        that the conversion is limited by the underlying OS, 
    187                         and will fail to operate correctly with Time values  
    188                         beyond the domain. On Win32 the earliest representable  
    189                         date is 1601. On linux it is 1970. Both systems have  
    190                         limitations upon future dates also. Date is limited  
    191                         to millisecond accuracy at best. 
     191                        and will fail to operate correctly with DateTime 
     192                        values beyond the domain. On Win32 the earliest 
     193                        representable date is 1601. On linux it is 1970. Both 
     194                        systems have limitations upon future dates also. Date 
     195                        is limited to millisecond accuracy at best. 
    192196 
    193197                **************************************************************/ 
    194198 
    195                 static Date toDate (Time time) 
     199                static Date toDate (DateTime time) 
    196200                { 
    197201                        Date date = void; 
     
    214218                /*************************************************************** 
    215219 
    216                         Convert Date fields to Time 
     220                        Convert Date fields to DateTime 
    217221 
    218222                        Note that the conversion is limited by the underlying  
    219                         OS, and will not operate correctly with Time values  
    220                         beyond the domain. On Win32 the earliest representable  
    221                         date is 1601. On linux it is 1970. Both systems have  
    222                         limitations upon future dates also. Date is limited  
    223                         to millisecond accuracy at best. 
    224  
    225                 ***************************************************************/ 
    226  
    227                 static Time fromDate (inout Date date) 
     223                        OS, and will not operate correctly with DateTime 
     224                        values beyond the domain. On Win32 the earliest 
     225                        representable date is 1601. On linux it is 1970. Both 
     226                        systems have limitations upon future dates also. Date 
     227                        is limited to millisecond accuracy at best. 
     228 
     229                ***************************************************************/ 
     230 
     231                static DateTime fromDate (inout Date date) 
    228232                { 
    229233                        tm t = void; 
     
    237241 
    238242                        auto seconds = timegm (&t); 
    239                         return cast(Time) (Time.TicksTo1970 + 
    240                                            Time.TicksPerSecond * seconds + 
    241                                            Time.TicksPerMillisecond * date.ms); 
    242                 } 
    243  
    244                 /*************************************************************** 
    245  
    246                         Convert timeval to a Time 
    247  
    248                 ***************************************************************/ 
    249  
    250                 package static Time convert (inout timeval tv) 
    251                 { 
    252                         return cast(Time) (Time.TicksTo1970 + (1_000_000L * tv.tv_sec + tv.tv_usec) * 10); 
    253                 } 
    254  
    255                 /*************************************************************** 
    256  
    257                         Convert Time to a timeval 
    258  
    259                 ***************************************************************/ 
    260  
    261                 package static timeval convert (Time time) 
     243                        return DateTime.epoch1970 + TimeSpan.seconds(seconds) + TimeSpan.milliseconds(date.ms); 
     244                } 
     245 
     246                /*************************************************************** 
     247 
     248                        Convert timeval to a DateTime 
     249 
     250                ***************************************************************/ 
     251 
     252                package static DateTime convert (inout timeval tv) 
     253                { 
     254                        return DateTime.epoch1970 + TimeSpan.seconds(tv.tv_sec) + TimeSpan.microseconds(tv.tv_usec); 
     255                } 
     256 
     257                /*************************************************************** 
     258 
     259                        Convert DateTime to a timeval 
     260 
     261                ***************************************************************/ 
     262 
     263                package static timeval convert (DateTime time) 
    262264                { 
    263265                        timeval tv = void; 
    264266 
    265                         time -= time.TicksTo1970; 
    266                         assert (time >= 0); 
    267                         time /= 10L; 
    268                         tv.tv_sec  = cast (typeof(tv.tv_sec))  (time / 1_000_000L); 
    269                         tv.tv_usec = cast (typeof(tv.tv_usec)) (time - 1_000_000L * tv.tv_sec); 
     267                        TimeSpan span = time - time.epoch1970; 
     268                        assert (span >= TimeSpan.zero); 
     269                        tv.tv_sec  = span.seconds; 
     270                        tv.tv_usec = span.microseconds % 1_000_000L; 
    270271                        return tv; 
    271272                } 
     
    282283                assert (Clock.convert(Clock.convert(time)) is time); 
    283284 
    284                 time = cast(Time) ((time / Time.TicksPerSecond) * Time.TicksPerSecond); 
     285                time -= TimeSpan(time.ticks % TimeSpan.second.ticks); 
    285286                auto date = Clock.toDate(time); 
    286287 
  • trunk/tango/util/time/DateTime.d

    r2897 r2900  
    1616private import  tango.util.time.Clock, 
    1717                tango.util.time.WallClock; 
     18 
     19public import tango.core.TimeSpan; 
    1820 
    1921/****************************************************************************** 
     
    2527        9999 AD. 
    2628 
    27         Time values are measured in 100-nanosecond intervals, or ticks.  
     29        DateTime values are measured in 100-nanosecond intervals, or ticks.  
    2830        A date value is the number of ticks that have elapsed since  
    2931        12:00:00 midnight on January 1, 0001 AD in the Gregorian  
     
    5658 
    5759        /// Represents the smallest and largest DateTime value. 
    58         public static final DateTime    min = {0}, 
    59                                         max = {Time.DaysTo10000 * Time.TicksPerDay - 1}; 
     60        public static const DateTime    min = {0}, 
     61                                        max = {(TimeSpan.DaysPer400Years * 25 - 366) * TimeSpan.TicksPerDay - 1}, 
     62                                        epoch1601 = {TimeSpan.DaysPer400Years * 4 * TimeSpan.TicksPerDay}, 
     63                                        epoch1970 = {TimeSpan.DaysPer400Years * 4 * TimeSpan.TicksPerDay + TimeSpan.TicksPerSecond * 11644473600L}; 
    6064 
    6165        private static final int[] DaysToMonthCommon =  
     
    105109        static DateTime opCall (long ticks)  
    106110        { 
    107                 DateTime d; 
    108                 d.ticks = ticks; 
     111                DateTime d = {ticks}; 
    109112                return d; 
    110         } 
    111  
    112         /********************************************************************** 
    113  
    114                 $(I Constructor.) Initializes a new instance of the  
    115                 DateTime struct to the specified Time. 
    116  
    117                 Params: time = A Tango time expressed in units of 100  
    118                 nanoseconds. 
    119  
    120         **********************************************************************/ 
    121  
    122         static DateTime opCall (Time time)  
    123         { 
    124                 return opCall (cast(long) time); 
    125113        } 
    126114 
     
    159147        static DateTime now ()  
    160148        { 
    161                 return DateTime (WallClock.now)
     149                return WallClock.now
    162150        } 
    163151 
     
    174162        static DateTime utc ()  
    175163        { 
    176                 return DateTime (Clock.now)
     164                return Clock.now
    177165        } 
    178166 
     
    199187        int opCmp (DateTime t)  
    200188        { 
    201                 if (ticks < t.ticks) 
    202                     return -1; 
    203                 else  
    204                    if (ticks > t.ticks) 
    205                        return 1; 
    206                 return 0; 
     189                return cast(int)((ticks - t.ticks) >>> 32); 
    207190        } 
    208191 
     
    212195                returning a new date and time. 
    213196                 
    214                 Params:  t = A DateTime value. 
     197                Params:  t = A TimeSpan value. 
    215198                Returns: A DateTime that is the sum of this instance and t. 
    216199 
    217200        **********************************************************************/ 
    218201 
    219         DateTime opAdd (DateTime t)  
     202        DateTime opAdd (TimeSpan t)  
    220203        { 
    221204                return DateTime (ticks + t.ticks); 
     
    227210                the result to this instance. 
    228211 
    229                 Params:  t = A DateTime value. 
     212                Params:  t = A TimeSpan value. 
    230213                Returns: The current DateTime instance, with t added to the  
    231214                         date and time. 
     
    233216        **********************************************************************/ 
    234217 
    235         DateTime opAddAssign (DateTime t)  
     218        DateTime opAddAssign (TimeSpan t)  
    236219        { 
    237220                ticks += t.ticks; 
     
    244227                returning a new date and time. 
    245228 
    246                 Params:  t = A DateTime value. 
     229                Params:  t = A TimeSpan value. 
    247230                Returns: A DateTime whose value is the value of this instance  
    248231                         minus the value of t. 
     
    250233        **********************************************************************/ 
    251234 
    252         DateTime opSub (DateTime t)  
     235        DateTime opSub (TimeSpan t)  
    253236        { 
    254237                return DateTime (ticks - t.ticks); 
     238        } 
     239 
     240        /********************************************************************** 
     241 
     242                Returns a time span which represents the difference in time 
     243                between this and the given DateTime. 
     244 
     245                Params:  t = A DateTime value. 
     246                Returns: A TimeSpan which represents the difference between 
     247                         this and t. 
     248 
     249        **********************************************************************/ 
     250 
     251        TimeSpan opSub (DateTime t) 
     252        { 
     253                return TimeSpan(ticks - t.ticks); 
    255254        } 
    256255 
     
    260259                assigning the result to this instance. 
    261260 
    262                 Params:  t = A DateTime value. 
     261                Params:  t = A TimeSpan value. 
    263262                Returns: The current DateTime instance, with t subtracted  
    264263                         from the date and time. 
     
    266265        **********************************************************************/ 
    267266 
    268         DateTime opSubAssign (DateTime t)  
     267        DateTime opSubAssign (TimeSpan t)  
    269268        { 
    270269                ticks -= t.ticks; 
     
    276275                Adds the specified number of ticks to the _value of this  
    277276                instance. 
     277                 
     278                Deprecated: use x + TimeSpan(value) instead. 
    278279 
    279280                Params:  value = The number of ticks to add. 
     
    283284        **********************************************************************/ 
    284285 
    285         DateTime addTicks (long value)  
     286        deprecated DateTime addTicks (long value)  
    286287        { 
    287288                return DateTime (ticks + value); 
     
    291292                Adds the specified number of hours to the _value of this  
    292293                instance. 
     294 
     295                Deprecated: use x + TimeSpan.hours(value) instead. 
    293296 
    294297                Params:  value = The number of hours to add. 
     
    299302        **********************************************************************/ 
    300303 
    301         DateTime addHours (int value)  
    302         { 
    303                 return addMilliseconds (value * Time.MillisPerHour); 
     304        deprecated DateTime addHours (int value)  
     305        { 
     306                return *this + TimeSpan.hours(value); 
    304307        } 
    305308 
     
    308311                Adds the specified number of minutes to the _value of this  
    309312                instance. 
     313 
     314                Deprecated: use x + TimeSpan.minutes(value); 
    310315 
    311316                Params:  value = The number of minutes to add. 
     
    316321        **********************************************************************/ 
    317322 
    318         DateTime addMinutes (int value)  
    319         { 
    320                 return addMilliseconds (value * Time.MillisPerMinute); 
     323        deprecated DateTime addMinutes (int value)  
     324        { 
     325                return *this + TimeSpan.minutes(value); 
    321326        } 
    322327 
     
    325330                Adds the specified number of seconds to the _value of this  
    326331                instance. 
     332 
     333                Deprecated: use x + TimeSpan.seconds(value) instead. 
    327334 
    328335                Params:  value = The number of seconds to add. 
     
    333340        **********************************************************************/ 
    334341 
    335         DateTime addSeconds (int value)  
    336         { 
    337                 return addMilliseconds (value * Time.MillisPerSecond); 
     342        deprecated DateTime addSeconds (int value)  
     343        { 
     344                return *this + TimeSpan.seconds(value); 
    338345        } 
    339346 
     
    342349                Adds the specified number of milliseconds to the _value of  
    343350                this instance. 
     351 
     352                Deprecated: use x + TimeSpan.milliseconds(value) instead. 
    344353 
    345354                Params:  value = The number of milliseconds to add. 
     
    350359        **********************************************************************/ 
    351360 
    352         DateTime addMilliseconds (long value)  
    353         { 
    354                 return addTicks (value * Time.TicksPerMillisecond); 
     361        deprecated DateTime addMilliseconds (long value)  
     362        { 
     363                return *this + TimeSpan.milliseconds(value); 
    355364        } 
    356365 
     
    359368                Adds the specified number of days to the _value of this  
    360369                instance. 
     370 
     371                Deprecated: use x + TimeSpan.days(value) instead. 
    361372 
    362373                Params:  value = The number of days to add. 
     
    367378        **********************************************************************/ 
    368379 
    369         DateTime addDays (int value)  
    370         { 
    371                 return addMilliseconds (value * Time.MillisPerDay); 
     380        deprecated DateTime addDays (int value)  
     381        { 
     382                return *this + TimeSpan.days(value); 
    372383        } 
    373384 
     
    405416                    day = maxDays; 
    406417 
    407                 return DateTime (getDateTicks(year, month, day) + (ticks % Time.TicksPerDay)); 
     418                return DateTime (getDateTicks(year, month, day) + (ticks % TimeSpan.day.ticks)); 
    408419        } 
    409420 
     
    487498        DayOfWeek dayOfWeek ()  
    488499        { 
    489                 return cast(DayOfWeek) ((ticks / Time.TicksPerDay + 1) % 7); 
     500                return cast(DayOfWeek) ((ticks / TimeSpan.day.ticks + 1) % 7); 
    490501        } 
    491502 
     
    500511        int hour ()  
    501512        { 
    502                 return cast(int) ((ticks / Time.TicksPerHour) % 24); 
     513                return cast(int) ((ticks / TimeSpan.hour.ticks) % 24); 
    503514        } 
    504515 
     
    513524        int minute ()  
    514525        { 
    515                 return cast(int) ((ticks / Time.TicksPerMinute) % 60); 
     526                return cast(int) ((ticks / TimeSpan.minute.ticks) % 60); 
    516527        } 
    517528 
     
    526537        int second ()  
    527538        { 
    528                 return cast(int) ((ticks / Time.TicksPerSecond) % 60); 
     539                return cast(int) ((ticks / TimeSpan.second.ticks) % 60); 
    529540        } 
    530541 
     
    540551        int millisecond ()  
    541552        { 
    542                 return cast(int) ((ticks / Time.TicksPerMillisecond) % 1000); 
     553                return cast(int) ((ticks / TimeSpan.ms.ticks) % 1000); 
    543554        } 
    544555 
     
    554565        DateTime date ()  
    555566        { 
    556                 auto ticks = this.ticks; 
    557                 return DateTime (ticks - ticks % Time.TicksPerDay); 
     567                return *this - timeOfDay; 
    558568        } 
    559569 
     
    566576        **********************************************************************/ 
    567577 
    568         DateTime timeOfDay ()  
    569         { 
    570                 return DateTime (ticks % Time.TicksPerDay); 
    571         } 
    572  
    573         /********************************************************************** 
    574  
    575                 $(I Property.) Retrieves a Time value representing the  
    576                 date and time of this instance. 
    577  
    578                 Returns: A Time represented by the date and time of this  
     578        TimeSpan timeOfDay ()  
     579        { 
     580                return TimeSpan (ticks % TimeSpan.day.ticks); 
     581        } 
     582 
     583        /********************************************************************** 
     584 
     585                $(I Property.) Retrieves the number of ticks for this DateTime 
     586 
     587                Deprecated: access ticks directly 
     588 
     589                Returns: A long represented by the date and time of this  
    579590                         instance. 
    580591 
    581592        **********************************************************************/ 
    582593 
    583         Time time ()  
    584         { 
    585                 return cast(Time) ticks; 
     594        deprecated long time ()  
     595        { 
     596                return ticks; 
    586597        } 
    587598 
     
    629640                --year; 
    630641                return (year * 365 + year / 4 - year / 100 + year / 400 +  
    631                         monthDays[month - 1] + day - 1) * Time.TicksPerDay
     642                        monthDays[month - 1] + day - 1) * TimeSpan.day.ticks
    632643        } 
    633644 
     
    638649        private static void splitDate (long ticks, out int year, out int month, out int day, out int dayOfYear)  
    639650        { 
    640                 int numDays = cast(int) (ticks / Time.TicksPerDay); 
    641                 int whole400Years = numDays / cast(int) Time.DaysPer400Years; 
    642                 numDays -= whole400Years * cast(int) Time.DaysPer400Years; 
    643                 int whole100Years = numDays / cast(int) Time.DaysPer100Years; 
     651                int numDays = cast(int) (ticks / TimeSpan.day.ticks); 
     652                int whole400Years = numDays / cast(int) TimeSpan.DaysPer400Years; 
     653                numDays -= whole400Years * cast(int) TimeSpan.DaysPer400Years; 
     654                int whole100Years = numDays / cast(int) TimeSpan.DaysPer100Years; 
    644655                if (whole100Years == 4) 
    645656                    whole100Years = 3; 
    646657 
    647                 numDays -= whole100Years * cast(int) Time.DaysPer100Years; 
    648                 int whole4Years = numDays / cast(int) Time.DaysPer4Years; 
    649                 numDays -= whole4Years * cast(int) Time.DaysPer4Years; 
    650                 int wholeYears = numDays / cast(int) Time.DaysPerYear; 
     658                numDays -= whole100Years * cast(int) TimeSpan.DaysPer100Years; 
     659                int whole4Years = numDays / cast(int) TimeSpan.DaysPer4Years; 
     660                numDays -= whole4Years * cast(int) TimeSpan.DaysPer4Years; 
     661                int wholeYears = numDays / cast(int) TimeSpan.DaysPerYear; 
    651662                if (wholeYears == 4) 
    652663                    wholeYears = 3; 
    653664 
    654665                year = whole400Years * 400 + whole100Years * 100 + whole4Years * 4 + wholeYears + 1; 
    655                 numDays -= wholeYears * Time.DaysPerYear; 
     666                numDays -= wholeYears * TimeSpan.DaysPerYear; 
    656667                dayOfYear = numDays + 1; 
    657668 
     
    700711        { 
    701712                auto d = DateTime(10); 
    702                 auto e = DateTime(20); 
     713                auto e = TimeSpan(20); 
    703714 
    704715                return d + e; 
  • trunk/tango/util/time/ISO8601.d

    r2809 r2900  
    1717        intervals, because I got too lazy to implement them. The functions  
    1818        (iso8601Time, iso8601Date, and iso8601) update a Date passed instead  
    19         of a Time, as does the current iso8601, because that's too limited a  
    20         format. One can always convert to a Time if necessary, keeping in mind  
    21         that information loss might occur if the Date is outside the interval  
    22         Time can represent. 
     19        of a DateTime, as does the current iso8601, because that's too limited 
     20        a format. One can always convert to a DateTime if necessary, keeping 
     21        in mind that information loss might occur if the Date is outside the 
     22        interval DateTime can represent. 
    2323 
    2424        In addition, because its dayOfWeek function only works for 1900-3-1 to  
  • trunk/tango/util/time/StopWatch.d

    r2878 r2900  
    1414 
    1515private import tango.core.Exception; 
    16  
    17 public  import tango.core.Type : Interval; 
    1816 
    1917/******************************************************************************* 
     
    4745        // ... 
    4846 
    49         Interval i = elapsed.stop; 
     47        double i = elapsed.stop; 
    5048        --- 
    5149 
     
    6866{ 
    6967        private ulong  started; 
    70         private static Interval multiplier = 1.0 / 1_000_000.0; 
     68        private static double multiplier = 1.0 / 1_000_000.0; 
    7169 
    7270        version (Win32) 
    73                  private static Interval microsecond; 
     71                 private static double microsecond; 
    7472 
    7573        /*********************************************************************** 
     
    9088        ***********************************************************************/ 
    9189         
    92         Interval stop () 
     90        double stop () 
    9391        { 
    9492                return multiplier * (timer - started); 
  • trunk/tango/util/time/WallClock.d

    r2809 r2900  
    1818                tango.util.time.Clock; 
    1919 
    20 public  import  tango.core.Type : Time; 
     20public import  tango.core.TimeSpan; 
     21 
     22public  import  tango.util.time.DateTime; 
    2123 
    2224/****************************************************************************** 
     
    2426        Exposes wall-time relative to Jan 1st, 1 AD. These values are 
    2527        based upon a clock-tick of 100ns, giving them a span of greater 
    26         than 10,000 years. Units of Time are the foundation of most time 
    27         and date functionality in Tango. 
     28        than 10,000 years. These Units of time are the foundation of most 
     29        time and date functionality in Tango. 
    2830 
    2931        Please note that conversion between UTC and Wall time is performed 
     
    4749                ***************************************************************/ 
    4850 
    49                 static Time now () 
    50                 { 
    51                         return cast(Time) (Clock.now - localBias)
     51                static DateTime now () 
     52                { 
     53                        return Clock.now - localBias
    5254                } 
    5355 
     
    5961                ***************************************************************/ 
    6062 
    61                 static Time zone () 
     63                static TimeSpan zone () 
    6264                { 
    6365                        TIME_ZONE_INFORMATION tz = void; 
    6466 
    6567                        auto tmp = GetTimeZoneInformation (&tz); 
    66                         return cast(Time) (-Time.TicksPerMinute * tz.Bias); 
     68                        return TimeSpan.minutes(-tz.Bias); 
    6769                } 
    6870 
     
    8890                ***************************************************************/ 
    8991 
    90                 static Date toDate (Time utc) 
    91                 { 
    92                         return Clock.toDate (cast(Time) (utc - localBias)); 
     92                static Date toDate (DateTime utc) 
     93                { 
     94                        return Clock.toDate (utc - localBias); 
    9395                } 
    9496 
     
    99101                ***************************************************************/ 
    100102 
    101                 static Time fromDate (inout Date date) 
    102                 { 
    103                         return cast(Time) (Clock.fromDate(date) + localBias); 
     103                static DateTime fromDate (inout Date date) 
     104                { 
     105                        return (Clock.fromDate(date) + localBias); 
    104106                } 
    105107 
     
    131133                              }  
    132134 
    133                        return Time.TicksPerMinute * bias;  
     135                       return TimeSpan.minutes(bias);  
    134136               } 
    135137        } 
     
    143145                ***************************************************************/ 
    144146 
    145                 static Time now () 
     147                static DateTime now () 
    146148                { 
    147149                        tm t = void; 
     
    160162                ***************************************************************/ 
    161163 
    162                 static Time zone () 
     164                static TimeSpan zone () 
    163165                { 
    164166                        version (darwin) 
     
    166168                                timezone_t tz = void; 
    167169                                gettimeofday (null, &tz); 
    168                                 return cast(Time) (-Time.TicksPerMinute * tz.tz_minuteswest); 
     170                                return TimeSpan.minutes(-tz.tz_minuteswest); 
    169171                                } 
    170172                             else 
    171                                 return cast(Time) (-Time.TicksPerSecond * timezone); 
     173                                return TimeSpan.seconds(-timezone); 
    172174                } 
    173175 
     
    193195                ***************************************************************/ 
    194196 
    195                 static Date toDate (Time utc) 
     197                static Date toDate (DateTime utc) 
    196198                { 
    197199                        Date date = void; 
     
    218220                ***************************************************************/ 
    219221 
    220                 static Time fromDate (inout Date date) 
     222                static DateTime fromDate (inout Date date) 
    221223                { 
    222224                        tm t = void; 
     
    230232 
    231233                        auto seconds = mktime (&t); 
    232                         return cast(Time) (Time.TicksTo1970 + 
    233                                            Time.TicksPerSecond * seconds + 
    234                                            Time.TicksPerMillisecond * date.ms); 
     234                        return DateTime.epoch1970 + TimeSpan.seconds(seconds) + TimeSpan.milliseconds(date.ms); 
    235235                } 
    236236        } 
     
    240240        ***********************************************************************/ 
    241241         
    242         static Time toLocal (Time utc) 
    243         { 
    244                 auto mod = utc % Time.TicksPerMillisecond
    245                 return cast(Time) (Clock.fromDate(toDate(utc)) + mod); 
     242        static DateTime toLocal (DateTime utc) 
     243        { 
     244                auto mod = utc.ticks % TimeSpan.ms.ticks
     245                return Clock.fromDate(toDate(utc)) + TimeSpan(mod); 
    246246        } 
    247247 
     
    250250        ***********************************************************************/ 
    251251         
    252         static Time toUtc (Time wall) 
    253         { 
    254                 auto mod = wall % Time.TicksPerMillisecond
    255                 return cast(Time) (fromDate(Clock.toDate(wall)) + mod); 
     252        static DateTime toUtc (DateTime wall) 
     253        { 
     254                auto mod = wall.ticks % TimeSpan.ms.ticks
     255                return fromDate(Clock.toDate(wall)) + TimeSpan(mod); 
    256256        } 
    257257} 
  • trunk/tango/util/time/chrono/Calendar.d

    r2878 r2900  
    1515 
    1616private import tango.core.Exception; 
    17  
    18 public  import tango.core.Type : Time; 
    1917 
    2018public  import tango.util.time.DateTime; 
     
    286284        package static long getTimeTicks (int hour, int minute, int second)  
    287285        { 
    288                 return (cast(long) hour * 3600 + cast(long) minute * 60 + cast(long) second) * Time.TicksPerSecond
     286                return (TimeSpan.hours(hour) + TimeSpan.minutes(minute) + TimeSpan.seconds(second)).ticks
    289287        } 
    290288} 
  • trunk/tango/util/time/chrono/Gregorian.d

    r2809 r2900  
    7070        override DateTime getDateTime(int year, int month, int day, int hour, int minute, int second, int millisecond, int era)  
    7171        { 
    72                 return DateTime (getDateTicks(year, month, day) + getTimeTicks(hour, minute, second) + (millisecond * Time.TicksPerMillisecond)); 
     72                return DateTime (getDateTicks(year, month, day) + getTimeTicks(hour, minute, second)) + TimeSpan.milliseconds(millisecond); 
    7373        } 
    7474 
     
    8080        override DateTime.DayOfWeek getDayOfWeek(DateTime time)  
    8181        { 
    82                 return cast(DateTime.DayOfWeek)((time.ticks / Time.TicksPerDay + 1) % 7); 
     82                return cast(DateTime.DayOfWeek)((time.ticks / TimeSpan.day.ticks + 1) % 7); 
    8383        } 
    8484 
     
    219219        package static void splitDate (long ticks, out int year, out int month, out int day, out int dayOfYear)  
    220220        { 
    221                 int numDays = cast(int)(ticks / Time.TicksPerDay); 
    222                 int whole400Years = numDays / cast(int) Time.DaysPer400Years; 
    223                 numDays -= whole400Years * cast(int) Time.DaysPer400Years; 
    224                 int whole100Years = numDays / cast(int) Time.DaysPer100Years; 
     221                int numDays = cast(int)(ticks / TimeSpan.day.ticks); 
     222                int whole400Years = numDays / cast(int) TimeSpan.DaysPer400Years; 
     223                numDays -= whole400Years * cast(int) TimeSpan.DaysPer400Years; 
     224                int whole100Years = numDays / cast(int) TimeSpan.DaysPer100Years; 
    225225                if (whole100Years == 4) 
    226226                    whole100Years = 3; 
    227227 
    228                 numDays -= whole100Years * cast(int) Time.DaysPer100Years; 
    229                 int whole4Years = numDays / cast(int) Time.DaysPer4Years; 
    230                 numDays -= whole4Years * cast(int) Time.DaysPer4Years; 
    231                 int wholeYears = numDays / cast(int) Time.DaysPerYear; 
     228                numDays -= whole100Years * cast(int) TimeSpan.DaysPer100Years; 
     229                int whole4Years = numDays / cast(int) TimeSpan.DaysPer4Years; 
     230                numDays -= whole4Years * cast(int) TimeSpan.DaysPer4Years; 
     231                int wholeYears = numDays / cast(int) TimeSpan.DaysPerYear; 
    232232                if (wholeYears == 4) 
    233233                    wholeYears = 3; 
    234234 
    235235                year = whole400Years * 400 + whole100Years * 100 + whole4Years * 4 + wholeYears + 1; 
    236                 numDays -= wholeYears * Time.DaysPerYear; 
     236                numDays -= wholeYears * TimeSpan.DaysPerYear; 
    237237                dayOfYear = numDays + 1; 
    238238 
     
    267267                int[] monthDays = isLeapYear(year, AD_ERA) ? DaysToMonthLeap : DaysToMonthCommon; 
    268268                year--; 
    269                 return (year * 365 + year / 4 - year / 100 + year / 400 + monthDays[month - 1] + day - 1) * Time.TicksPerDay
     269                return (year * 365 + year / 4 - year / 100 + year / 400 + monthDays[month - 1] + day - 1) * TimeSpan.day.ticks
    270270        } 
    271271} 
  • trunk/tango/util/time/chrono/Hebrew.d

    r2878 r2900  
    7979   */ 
    8080  public override DateTime.DayOfWeek getDayOfWeek(DateTime time) { 
    81     return cast(DateTime.DayOfWeek) cast(int) ((time.ticks / Time.TicksPerDay + 1) % 7); 
     81    return cast(DateTime.DayOfWeek) cast(int) ((time.ticks / TimeSpan.day.ticks + 1) % 7); 
    8282  } 
    8383 
     
    9191    int yearType = getYearType(year); 
    9292    int days = getStartOfYear(year) - DaysToOneAD; 
    93     int day = cast(int)(time.ticks / Time.TicksPerDay) - days; 
     93    int day = cast(int)(time.ticks / TimeSpan.day.ticks) - days; 
    9494    int n; 
    9595    while (n < 12 && day >= MonthDays[yearType][n + 1]) { 
     
    108108    int year = getYear(time); 
    109109    int days = getStartOfYear(year) - DaysToOneAD; 
    110     return (cast(int)(time.ticks / Time.TicksPerDay) - days) + 1; 
     110    return (cast(int)(time.ticks / TimeSpan.day.ticks) - days) + 1; 
    111111  } 
    112112 
     
    120120    int yearType = getYearType(year); 
    121121    int days = getStartOfYear(year) - DaysToOneAD; 
    122     int day = cast(int)(time.ticks / Time.TicksPerDay) - days; 
     122    int day = cast(int)(time.ticks / TimeSpan.day.ticks) - days; 
    123123    int n; 
    124124    while (n < 12 && day >= MonthDays[yearType][n + 1]) { 
     
    135135   */ 
    136136  public override int getYear(DateTime time) { 
    137     int day = cast(int)(time.ticks / Time.TicksPerDay) + DaysToOneAD; 
     137    int day = cast(int)(time.ticks / TimeSpan.day.ticks) + DaysToOneAD; 
    138138    int low = minYear_, high = maxYear_; 
    139139    // Perform a binary search. 
     
    282282    for (int i = 1; i <= month; i++) 
    283283      days += MonthDays[yearType][i - 1]; 
    284     return DateTime((days * Time.TicksPerDay) + getTimeTicks(hour, minute, second) + (millisecond * Time.TicksPerMillisecond)); 
     284    return DateTime((days * TimeSpan.day.ticks) + getTimeTicks(hour, minute, second)) + TimeSpan.milliseconds(millisecond); 
    285285  } 
    286286 
  • trunk/tango/util/time/chrono/Hijri.d

    r2809 r2900  
    4444   */ 
    4545  public override DateTime getDateTime(int year, int month, int day, int hour, int minute, int second, int millisecond, int era) { 
    46     return DateTime((daysSinceJan1(year, month, day) - 1) * Time.TicksPerDay + getTimeTicks(hour, minute, second) + (millisecond * Time.TicksPerMillisecond)); 
     46    return DateTime((daysSinceJan1(year, month, day) - 1) * TimeSpan.day.ticks + getTimeTicks(hour, minute, second)) + TimeSpan.milliseconds(millisecond); 
    4747  } 
    4848 
     
    5353   */ 
    5454  public override DateTime.DayOfWeek getDayOfWeek(DateTime time) { 
    55     return cast(DateTime.DayOfWeek) (cast(int) (time.ticks / Time.TicksPerDay + 1) % 7); 
     55    return cast(DateTime.DayOfWeek) (cast(int) (time.ticks / TimeSpan.day.ticks + 1) % 7); 
    5656  } 
    5757 
     
    180180 
    181181  private int extractPart(long ticks, DatePart part) { 
    182     long days = (ticks / Time.TicksPerDay + 1)
     182    long days = TimeSpan(ticks).days + 1
    183183    int year = cast(int)(((days - 227013) * 30) / 10631) + 1; 
    184184    long daysUpToYear = daysToYear(year);