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

Changeset 3857

Show
Ignore:
Timestamp:
08/05/08 11:59:05 (4 years ago)
Author:
schveiguy
Message:

Changed static TimeSpan? methods to be e.g. fromSeconds instead of seconds. This fixes #1184

THIS IS A BREAKING CHANGE

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/tango/io/Path.d

    r3849 r3857  
    711711                        { 
    712712                                return Time.epoch1970 + 
    713                                        TimeSpan.seconds(tv.tv_sec) + 
    714                                        TimeSpan.micros(tv.tv_usec); 
     713                                       TimeSpan.fromSeconds(tv.tv_sec) + 
     714                                       TimeSpan.fromMicros(tv.tv_usec); 
    715715                        } 
    716716 
  • trunk/tango/io/selector/AbstractSelector.d

    r3851 r3857  
    253253    public int select(double timeout) 
    254254    { 
    255             return select(TimeSpan.interval(timeout)); 
     255            return select(TimeSpan.fromInterval(timeout)); 
    256256    } 
    257257 
  • trunk/tango/net/SocketPool.d

    r3830 r3857  
    4949        private InternetAddress         address; 
    5050        private Connection              freelist; 
    51         private TimeSpan                timeout = TimeSpan.seconds(60); 
     51        private TimeSpan                timeout = TimeSpan.fromSeconds(60); 
    5252 
    5353 
  • trunk/tango/net/cluster/tina/Cluster.d

    r3723 r3857  
    10071007        private InternetAddress address; 
    10081008        private PoolConnection  freelist; 
    1009         private TimeSpan        timeout = TimeSpan.seconds(60); 
     1009        private TimeSpan        timeout = TimeSpan.fromSeconds(60); 
    10101010 
    10111011        /*********************************************************************** 
  • trunk/tango/net/ftp/Telnet.d

    r3038 r3857  
    3434 
    3535        /// The number of milliseconds to wait for socket communication or connection. 
    36         protected TimeSpan timeout = TimeSpan.millis(5000); 
     36        protected TimeSpan timeout = TimeSpan.fromMillis(5000); 
    3737 
    3838        /// provided by host 
  • trunk/tango/time/Clock.d

    r3204 r3857  
    242242                        auto seconds = timegm (&t); 
    243243                        return Time.epoch1970 +  
    244                                TimeSpan.seconds(seconds) +  
    245                                TimeSpan.millis(dt.time.millis); 
     244                               TimeSpan.fromSeconds(seconds) +  
     245                               TimeSpan.fromMillis(dt.time.millis); 
    246246                } 
    247247 
     
    255255                { 
    256256                        return Time.epoch1970 +  
    257                                TimeSpan.seconds(tv.tv_sec) +  
    258                                TimeSpan.micros(tv.tv_usec); 
     257                               TimeSpan.fromSeconds(tv.tv_sec) +  
     258                               TimeSpan.fromMicros(tv.tv_usec); 
    259259                } 
    260260 
  • trunk/tango/time/ISO8601.d

    r3448 r3857  
    858858 
    859859void addMonths(inout FullDate d, int n) { d.val = Gregorian.generic.addMonths(d.val, n-1); } // -1 due to initial being 1 
    860 void addDays  (inout FullDate d, int n) { d.val += TimeSpan.days   (n-1); } // ditto 
    861 void addHours (inout FullDate d, int n) { d.val += TimeSpan.hours  (n); } 
    862 void addMins  (inout FullDate d, int n) { d.val += TimeSpan.minutes(n); } 
    863 void addSecs  (inout FullDate d, int n) { d.val += TimeSpan.seconds(n); } 
    864 void addMs    (inout FullDate d, int n) { d.val += TimeSpan.millis (n); } 
     860void addDays  (inout FullDate d, int n) { d.val += TimeSpan.fromDays   (n-1); } // ditto 
     861void addHours (inout FullDate d, int n) { d.val += TimeSpan.fromHours  (n); } 
     862void addMins  (inout FullDate d, int n) { d.val += TimeSpan.fromMinutes(n); } 
     863void addSecs  (inout FullDate d, int n) { d.val += TimeSpan.fromSeconds(n); } 
     864void addMs    (inout FullDate d, int n) { d.val += TimeSpan.fromMillis (n); } 
    865865 
    866866// years and secs always just get the DT value 
  • trunk/tango/time/Time.d

    r3769 r3857  
    364364         * Returns: A TimeSpan representing the given number of nanoseconds. 
    365365         */ 
    366         static TimeSpan nanos(long value) 
     366        static TimeSpan fromNanos(long value) 
    367367        { 
    368368                return TimeSpan(value / NanosecondsPerTick); 
     
    375375         * Returns: A TimeSpan representing the given number of microseconds. 
    376376         */ 
    377         static TimeSpan micros(long value) 
     377        static TimeSpan fromMicros(long value) 
    378378        { 
    379379                return TimeSpan(TicksPerMicrosecond * value); 
     
    386386         * Returns: A TimeSpan representing the given number of milliseconds. 
    387387         */ 
    388         static TimeSpan millis(long value) 
     388        static TimeSpan fromMillis(long value) 
    389389        { 
    390390                return TimeSpan(TicksPerMillisecond * value); 
     
    397397         * Returns: A TimeSpan representing the given number of seconds. 
    398398         */ 
    399         static TimeSpan seconds(long value) 
     399        static TimeSpan fromSeconds(long value) 
    400400        { 
    401401                return TimeSpan(TicksPerSecond * value); 
     
    408408         * Returns: A TimeSpan representing the given number of minutes. 
    409409         */ 
    410         static TimeSpan minutes(long value) 
     410        static TimeSpan fromMinutes(long value) 
    411411        { 
    412412                return TimeSpan(TicksPerMinute * value); 
     
    419419         * Returns: A TimeSpan representing the given number of hours. 
    420420         */ 
    421         static TimeSpan hours(long value) 
     421        static TimeSpan fromHours(long value) 
    422422        { 
    423423                return TimeSpan(TicksPerHour * value); 
     
    430430         * Returns: A TimeSpan representing the given number of days. 
    431431         */ 
    432         static TimeSpan days(long value) 
     432        static TimeSpan fromDays(long value) 
    433433        { 
    434434                return TimeSpan(TicksPerDay * value); 
     
    443443         * Returns: A TimeSpan representing the given interval. 
    444444         */ 
    445         static TimeSpan interval(double sec) 
     445        static TimeSpan fromInterval(double sec) 
    446446        { 
    447447                return TimeSpan(cast(long)(sec * TicksPerSecond + .1)); 
     
    760760        TimeSpan span () 
    761761        { 
    762                 return TimeSpan.hours(hours) + 
    763                        TimeSpan.minutes(minutes) +  
    764                        TimeSpan.seconds(seconds) +  
    765                        TimeSpan.millis(millis); 
     762                return TimeSpan.fromHours(hours) + 
     763                       TimeSpan.fromMinutes(minutes) +  
     764                       TimeSpan.fromSeconds(seconds) +  
     765                       TimeSpan.fromMillis(millis); 
    766766        } 
    767767 
     
    829829                assert(TimeSpan.min <= TimeSpan.min); 
    830830 
    831                 assert (TimeSpan.seconds(50).seconds is 50); 
    832                 assert (TimeSpan.seconds(5000).seconds is 5000); 
    833                 assert (TimeSpan.minutes(50).minutes is 50); 
    834                 assert (TimeSpan.minutes(5000).minutes is 5000); 
    835                 assert (TimeSpan.hours(23).hours is 23); 
    836                 assert (TimeSpan.hours(5000).hours is 5000); 
    837                 assert (TimeSpan.days(6).days is 6); 
    838                 assert (TimeSpan.days(5000).days is 5000); 
    839  
    840                 assert (TimeSpan.seconds(50).time.seconds is 50); 
    841                 assert (TimeSpan.seconds(5000).time.seconds is 5000 % 60); 
    842                 assert (TimeSpan.minutes(50).time.minutes is 50); 
    843                 assert (TimeSpan.minutes(5000).time.minutes is 5000 % 60); 
    844                 assert (TimeSpan.hours(23).time.hours is 23); 
    845                 assert (TimeSpan.hours(5000).time.hours is 5000 % 24); 
     831                assert (TimeSpan.fromSeconds(50).seconds is 50); 
     832                assert (TimeSpan.fromSeconds(5000).seconds is 5000); 
     833                assert (TimeSpan.fromMinutes(50).minutes is 50); 
     834                assert (TimeSpan.fromMinutes(5000).minutes is 5000); 
     835                assert (TimeSpan.fromHours(23).hours is 23); 
     836                assert (TimeSpan.fromHours(5000).hours is 5000); 
     837                assert (TimeSpan.fromDays(6).days is 6); 
     838                assert (TimeSpan.fromDays(5000).days is 5000); 
     839 
     840                assert (TimeSpan.fromSeconds(50).time.seconds is 50); 
     841                assert (TimeSpan.fromSeconds(5000).time.seconds is 5000 % 60); 
     842                assert (TimeSpan.fromMinutes(50).time.minutes is 50); 
     843                assert (TimeSpan.fromMinutes(5000).time.minutes is 5000 % 60); 
     844                assert (TimeSpan.fromHours(23).time.hours is 23); 
     845                assert (TimeSpan.fromHours(5000).time.hours is 5000 % 24); 
    846846 
    847847                auto tod = TimeOfDay (25, 2, 3, 4); 
  • trunk/tango/time/WallClock.d

    r3042 r3857  
    6363 
    6464                        auto tmp = GetTimeZoneInformation (&tz); 
    65                         return TimeSpan.minutes(-tz.Bias); 
     65                        return TimeSpan.fromMinutes(-tz.Bias); 
    6666                } 
    6767 
     
    130130                              }  
    131131 
    132                        return TimeSpan.minutes(bias);  
     132                       return TimeSpan.fromMinutes(bias);  
    133133               } 
    134134        } 
     
    165165                                timezone_t tz = void; 
    166166                                gettimeofday (null, &tz); 
    167                                 return TimeSpan.minutes(-tz.tz_minuteswest); 
     167                                return TimeSpan.fromMinutes(-tz.tz_minuteswest); 
    168168                                } 
    169169                             else 
    170                                 return TimeSpan.seconds(-timezone); 
     170                                return TimeSpan.fromSeconds(-timezone); 
    171171                } 
    172172 
     
    231231 
    232232                        auto seconds = mktime (&t); 
    233                         return Time.epoch1970 + TimeSpan.seconds(seconds)  
    234                                               + TimeSpan.millis(dt.time.millis); 
     233                        return Time.epoch1970 + TimeSpan.fromSeconds(seconds)  
     234                                              + TimeSpan.fromMillis(dt.time.millis); 
    235235                } 
    236236        } 
  • trunk/tango/time/chrono/Calendar.d

    r3164 r3857  
    437437                for(int m = 0; m < nMonths; m++) 
    438438                        nDays += getDaysInMonth(year, m + 1, era); 
    439                 return t + TimeSpan.days(nDays); 
     439                return t + TimeSpan.fromDays(nDays); 
    440440        } 
    441441 
     
    468468        package static long getTimeTicks (uint hour, uint minute, uint second)  
    469469        { 
    470                 return (TimeSpan.hours(hour) + TimeSpan.minutes(minute) + TimeSpan.seconds(second)).ticks; 
     470                return (TimeSpan.fromHours(hour) + TimeSpan.fromMinutes(minute) + TimeSpan.fromSeconds(second)).ticks; 
    471471        } 
    472472} 
  • trunk/tango/time/chrono/Gregorian.d

    r3166 r3857  
    9090        override Time toTime (uint year, uint month, uint day, uint hour, uint minute, uint second, uint millisecond, uint era) 
    9191        { 
    92                 return Time (getDateTicks(year, month, day, era) + getTimeTicks(hour, minute, second)) + TimeSpan.millis(millisecond); 
     92                return Time (getDateTicks(year, month, day, era) + getTimeTicks(hour, minute, second)) + TimeSpan.fromMillis(millisecond); 
    9393        } 
    9494 
     
    471471                for(int i = 0; i < 366 + 365; i++) 
    472472                { 
    473                         t -= TimeSpan.days(1); 
     473                        t -= TimeSpan.fromDays(1); 
    474474                        output(t); 
    475475                } 
     
    484484                // check Gregorian date handles positive time. 
    485485                // 
    486                 Time t = Time.epoch + TimeSpan.days(365); 
     486                Time t = Time.epoch + TimeSpan.fromDays(365); 
    487487                Date d = Gregorian.generic.toDate(t); 
    488488                assert(d.year == 2); 
     
    499499                // check that it handles negative time 
    500500                // 
    501                 t = Time.epoch - TimeSpan.days(366); 
     501                t = Time.epoch - TimeSpan.fromDays(366); 
    502502                d = Gregorian.generic.toDate(t); 
    503503                assert(d.year == 1); 
     
    512512                // 2/3/2004, 04:05:06.007008, then subtract 15 months again. 
    513513                // 
    514                 t = Gregorian.generic.toTime(2004, 2, 3, 4, 5, 6, 7) + TimeSpan.micros(8); 
     514                t = Gregorian.generic.toTime(2004, 2, 3, 4, 5, 6, 7) + TimeSpan.fromMicros(8); 
    515515                d = Gregorian.generic.toDate(t); 
    516516                assert(d.year == 2004); 
  • trunk/tango/time/chrono/Hebrew.d

    r3040 r3857  
    282282    for (int i = 1; i <= month; i++) 
    283283      days += MonthDays[yearType][i - 1]; 
    284     return Time((days * TimeSpan.TicksPerDay) + getTimeTicks(hour, minute, second)) + TimeSpan.millis(millisecond); 
     284    return Time((days * TimeSpan.TicksPerDay) + getTimeTicks(hour, minute, second)) + TimeSpan.fromMillis(millisecond); 
    285285  } 
    286286 
  • trunk/tango/time/chrono/Hijri.d

    r3040 r3857  
    4444   */ 
    4545  public override Time toTime(uint year, uint month, uint day, uint hour, uint minute, uint second, uint millisecond, uint era) { 
    46     return Time((daysSinceJan1(year, month, day) - 1) * TimeSpan.TicksPerDay + getTimeTicks(hour, minute, second)) + TimeSpan.millis(millisecond); 
     46    return Time((daysSinceJan1(year, month, day) - 1) * TimeSpan.TicksPerDay + getTimeTicks(hour, minute, second)) + TimeSpan.fromMillis(millisecond); 
    4747  } 
    4848