Pick up at 8.5:00 AM?



  • When ordering a refill at a certain pharmacy, I was offered these choices for the pickup time:

    HTML source:

      <td style="width:442px;" align="left" colspan="2" class="myaccounttxt">
        <strong>Select Pickup Time</strong><br />
        <select name="hoursLeft" class="myaccounttxt"><option value=8.5>8.5:00 AM</option><option value=9.5>9.5:00 AM</option>
    <option value=10.5>
    10.5:00 AM</option><option value=11.5>11.5:00 AM</option><option value=12.5>0.5:00 PM</option>
    <option value=13.5>
    1.5:00 PM</option><option value=14.5>2.5:00 PM</option><option value=15.5>3.5:00 PM</option>
    <option value=16.5>
    4.5:00 PM</option><option value=17.5>5.5:00 PM</option><option value=18.5>6.5:00 PM</option>
    <option value=19.5>7.5:00 PM</option><option value=20.5>8.5:00 PM</option></select><br /><br /> </td>

     I bet this was generated by something like:

    for(double t = opening_time; t < closing_time; t += 1){
    if(t < 12)
    printf("<option value=%f>%f:00 AM</option>", t, t);
    else
    printf("<option value=%f>%f:00 PM</option>", t, t-12);
    }

    Here opening_time = 8.5, as we can see on the previous page:

     



  • Discourse touched me in a no-no place

    @apetrov87 said:

     I bet this was generated by something like:

    for(double t = opening_time; t < closing_time; t += 1){
    if(t < 12)
    printf("<option value=%f>%f:00 AM</option>", t, t);
    else
    printf("<option value=%f>%f:00 PM</option>", t, t-12);
    }
    Smells more like they used automatic conversion to string and concatenation:

    for (hourstype t = opening_time ; t < closing_time)
    if (t < 12)
    print("<option value=" + t + ">" + t +":00 AM</option>");
    else
    print("<option value=" + t + ">" + (t-12) +":00 AM</option>");
    Except I guess there was no real type declaration used for t at all (a C++-like auto is not a real variable type declaration). Had there been, someone might've actually spotted the problem ahead of time and we know that didn't happen. Either that or the maintenance developer (the page claims to be copyright 2006, so someone's been “maintaining” it) didn't grok why changing the type of the times might have consequences.

    I guess the original version just had integer hour opening times.



  • @dkf said:

    Except I guess there was no real type declaration used for t at all (a C++-like auto is not a real variable type declaration).

    Most likely they used an automatically typed language like Perl. Everything worked fine as long as they had opening_time = 8. Still, even then it would produce an entry of "0:00 PM".

     

     



  • It's clearly an Innovative Solution — I doubt many others have come up with a similar one.



  • @apetrov87 said:

    Everything worked fine as long as they had opening_time = 8. Still, even then it would produce an entry of "0:00 PM".

    Now that I think about it, they must've had a special case for t=12, which would still fail on t=12.5.

     

     



  • @apetrov87 said:

    @apetrov87 said:

    Everything worked fine as long as they had opening_time = 8. Still, even then it would produce an entry of "0:00 PM".

    Now that I think about it, they must've had a special case for t=12, which would still fail on t=12.5.

     

     


    Yeah: <=


Log in to reply