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

Changeset 3797 for trunk

Show
Ignore:
Timestamp:
07/24/08 16:59:47 (2 months ago)
Author:
schveiguy
Message:

Fixed date/time handling code
references #1204

Files:

Legend:

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

    r3765 r3797  
    22522252    year=((dosdate & 0b1111111_0000_00000) >> 9) + 1980; 
    22532253 
    2254     // This code sucks. 
    2255     scope cal = new Gregorian; 
    2256     time = Time.epoch 
    2257         + TimeSpan.days(cal.getDaysInYear(year, 0)) 
    2258         + TimeSpan.days(cal.getDaysInMonth(year, mon, 0)) 
    2259         + TimeSpan.days(day) 
    2260         + TimeSpan.hours(hour) 
    2261         + TimeSpan.minutes(min) 
    2262         + TimeSpan.seconds(sec); 
     2254    // This code rules! 
     2255    time = Gregorian.generic.toTime(year, mon, day, hour, min, sec); 
    22632256} 
    22642257 
     
    22692262        time = WallClock.now; 
    22702263 
    2271     // *muttering angrily* 
    2272     scope cal = new Gregorian; 
    2273  
    2274     if( cal.getYear(time) < 1980 ) 
     2264    // *muttering happily* 
     2265    auto date = Gregorian.generic.toDate(time); 
     2266    if( date.year < 1980 ) 
    22752267        ZipException.tooold; 
    22762268 
    2277     auto span = time.span
     2269    auto tod = time.time()
    22782270    dostime = cast(ushort) ( 
    2279         (span.seconds / 2) 
    2280       | (span.minutes << 5) 
    2281       | (span.hours   << 11)); 
     2271        (tod.seconds / 2) 
     2272      | (tod.minutes << 5) 
     2273      | (tod.hours   << 11)); 
    22822274 
    22832275    dosdate = cast(ushort) ( 
    2284         (cal.getDayOfMonth(time)
    2285       | (cal.getMonth(time) << 5) 
    2286       |((cal.getYear(time) - 1980) << 9)); 
     2276        (date.day
     2277      | (date.month << 5) 
     2278      | ((date.year - 1980) << 9)); 
    22872279} 
    22882280