VirtualBox

Changeset 86918 in vbox


Ignore:
Timestamp:
Nov 19, 2020 11:08:06 AM (4 years ago)
Author:
vboxsync
Message:

ValKit/utils.py: Made the timestamp parser treat the seconds part as optional, just like the javascript version of the code does. bugref:9787

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/common/utils.py

    r86588 r86918  
    15781578        sTime = sTime[1:];
    15791579
    1580     # HH:MM:SS
     1580    # HH:MM[:SS]
    15811581    iHour = int(sTime[0:2]);
    15821582    assert(sTime[2] == ':');
    15831583    iMin  = int(sTime[3:5]);
    1584     assert(sTime[5] == ':');
    1585     iSec  = int(sTime[6:8]);
    1586 
    1587     # Fraction?
    1588     offTime = 8;
    1589     iMicroseconds = 0;
    1590     if offTime < len(sTime) and sTime[offTime] in '.,':
    1591         offTime += 1;
    1592         cchFraction = 0;
    1593         while offTime + cchFraction < len(sTime) and sTime[offTime + cchFraction] in '0123456789':
    1594             cchFraction += 1;
    1595         if cchFraction > 0:
    1596             iMicroseconds = int(sTime[offTime : (offTime + cchFraction)]);
    1597             offTime += cchFraction;
    1598             while cchFraction < 6:
    1599                 iMicroseconds *= 10;
     1584    if (sTime[5] == ':')
     1585        iSec = int(sTime[6:8]);
     1586
     1587        # Fraction?
     1588        offTime = 8;
     1589        iMicroseconds = 0;
     1590        if offTime < len(sTime) and sTime[offTime] in '.,':
     1591            offTime += 1;
     1592            cchFraction = 0;
     1593            while offTime + cchFraction < len(sTime) and sTime[offTime + cchFraction] in '0123456789':
    16001594                cchFraction += 1;
    1601             while cchFraction > 6:
    1602                 iMicroseconds = iMicroseconds // 10;
    1603                 cchFraction -= 1;
     1595            if cchFraction > 0:
     1596                iMicroseconds = int(sTime[offTime : (offTime + cchFraction)]);
     1597                offTime += cchFraction;
     1598                while cchFraction < 6:
     1599                    iMicroseconds *= 10;
     1600                    cchFraction += 1;
     1601                while cchFraction > 6:
     1602                    iMicroseconds = iMicroseconds // 10;
     1603                    cchFraction -= 1;
     1604
     1605    else:
     1606        iSec          = 0;
     1607        iMicroseconds = 0;
     1608        offTime       = 5;
    16041609
    16051610    # Naive?
Note: See TracChangeset for help on using the changeset viewer.

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