Patrick (patrickwonders) wrote,
Patrick
patrickwonders

  • Mood:

Unintuitive

Say, for example, you're writing some code to classify something as active, recent, or upcoming. Say, for example, the something has a start-date of 01/22/2008. Say, for example, you're using Class::Date in perl.

You know that the Class::Date function date can take a variety of inputs: an array of year, month, day, hour, minute, second where the year defaults to 2000, the month and day default to 1, and the hour, minute, and second default to 0; a hash of year, month, day, hour, minute, second with the same defaults the array had; a 14-digit mysql-style timestamp YYYYMMDDhhmmss; a 32-bit unix timestamp; an ISO-like date YYYY-MM-DD hh:mm:ss.ffff where the ffff is ignored and the :ss is optional; or a variety of additional input formats.

Now, suppose you go ahead and call the date function giving it just 2008-01-22. What would you expect it to assume for the hours, minutes, and seconds? You'd probably expect 00:00:00. And, you'd be right.

Now, suppose you go ahead and call the date function giving it 01/22/2008. What would you expect it to assume for the hours, minutes, and seconds? You'd probably expect 00:00:00. And, you'd be wrong. It would use the current hours, minutes, and seconds. This will cause you great grief.

Tags: api, bug, perl, programming
Subscribe
  • Post a new comment

    Error

    default userpic

    Your reply will be screened

  • 7 comments